Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Im having a bit of trouble trying to change this telephone program to a void str

ID: 3625261 • Letter: I

Question

Im having a bit of trouble trying to change this telephone program to a void structure that asks for normal, updated and then prints the results.

#include
#include
#include
using namespace std;

int main ()

{
int accnum;
char service;
double minUsed, amountDue, dayUsed, nightUsed;
//set only two decimal places
cout << fixed << showpoint;
cout << setprecision(2);

//Get the account number from the user
cout << " Please enter your Account Number:";
cin >> accnum;
cout << endl;
//Get the service type from the user
cout << " Please enter your service plan:"
<< " N or n (Normal),"
<< " U or u (Updated):";
cin >> service;
cout << endl;
//use switch to determine service plan and rates.
switch (service)
{
case 'n':
cout <<" Normal";
case 'N':
cout << " Enter Number of Mintues";
cin >> minUsed;
cout << endl;
if ((minUsed - 50 ) < 0)
amountDue = 10.00;
else if((minUsed - 50) >0)
amountDue = (minUsed-50)* .20 + 10.00;
//output details

cout << " Account number: "
<< accnum
<< endl;
cout << " Total Minutes for Normal Service:"
<< minUsed
<
cout << " Amount Due: $"
<< amountDue
<< endl;
break;
// Service details and rates
case 'U':
cout << " Updated";
case 'u':
cout << " Enter Day Mintues";
cin >> dayUsed;
cout << endl;
cout << " Enter Night Mintues";
cin >> nightUsd;
cout << endl;
if ((dayUsed - 75 ) < 0)
amountDue = 25.00;
else if((dayUsed - 75) > 0)
amountDue = .10 * (dayUsed - 75) + 25.00;
if ((nightUsed - 100 ) < 0)
amountDue = 25.00;
else if((nightUsed - 100) >0)
amountDue = .05 * (nightUsed - 100) + 25.00;

//Output detials

cout << " Account number: "
<< accnum
<< endl;

cout << " Total Mintues for Updated Service:"
<< nightUsed + dayUsed
<< endl;
cout << " Amount Due: $"
<< amountDue
<< endl;


break;
default:
cout << "Invaild Entry." << endl;
}




system("PAUSE");

return 0;

}

I started tot try to create a function for the problem this is one for the normal service...but im stuck

//Value-returning function definition
//use switch to determine service plan and rates.
calcNormBill(double amountDue)
{
double minUsed, amountDue;
switch (service)
{
case 'n':
cout <<" Normal";
case 'N':
cout << " Enter Number of Mintues";
cin >> minUsed;
cout << endl;
if ((minUsed - 50 ) < 0)
amountDue = 10.00;
else if((minUsed - 50) >0)
amountDue = (minUsed-50)* .20 + 10.00;

return amountDue;
}

Thanks for all the help

Explanation / Answer

please rate - thanks

hope this is good


#include <iostream>
#include <iomanip>

using namespace std;
void calcNormBill( int);
void calcUpdatedBill(int);
int main ()

{
int accnum;
char service;
double minUsed, amountDue, dayUsed, nightUsed;
//set only two decimal places
cout << fixed << showpoint;
cout << setprecision(2);
//Get the account number from the user
cout << " Please enter your Account Number:";
cin >> accnum;
cout << endl;
//Get the service type from the user
cout << " Please enter your service plan:"
<< " N or n (Normal),"
<< " U or u (Updated):";
cin >> service;
cout << endl;
//use switch to determine service plan and rates.
switch (service)
{
case 'n':
case 'N':
calcNormBill(accnum);
break;
// Service details and rates
case 'U':
case 'u':
calcUpdatedBill(accnum);
break;
default:
cout << "Invaild Entry." << endl;
}
system("PAUSE");
return 0;
}
void calcNormBill(int accnum)
{double minUsed, amountDue;

cout <<" Normal";    
cout << " Enter Number of Mintues";
cin >> minUsed;
cout << endl;
if ((minUsed - 50 ) < 0)
amountDue = 10.00;
else if((minUsed - 50) >0)
amountDue = (minUsed-50)* .20 + 10.00;
//output details

cout << " Account number: "
<< accnum
<< endl;
cout << " Total Minutes for Normal Service:"
<< minUsed
<
cout << " Amount Due: $"
<< amountDue
<< endl;
}
void calcUpdatedBill(int accnum)
{double minUsed, amountDue, dayUsed, nightUsed;
cout << " Updated";    
cout << " Enter Day Mintues";
cin >> dayUsed;
cout << endl;
cout << " Enter Night Mintues";
cin >> nightUsed;
cout << endl;
if ((dayUsed - 75 ) < 0)
amountDue = 25.00;
else if((dayUsed - 75) > 0)
amountDue = .10 * (dayUsed - 75) + 25.00;
if ((nightUsed - 100 ) < 0)
amountDue = 25.00;
else if((nightUsed - 100) >0)
amountDue = .05 * (nightUsed - 100) + 25.00;

//Output detials

cout << " Account number: "
<< accnum
<< endl;

cout << " Total Mintues for Updated Service:"
<< nightUsed + dayUsed
<< endl;
cout << " Amount Due: $"
<< amountDue
<< endl;
}