I need a program wrote in C++ with an explanation after each line of code to sol
ID: 3637005 • Letter: I
Question
I need a program wrote in C++ with an explanation after each line of code to solve the problem below.An Internet service provider has three different subscription packages for it customers:
Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour.
Package B: For $14.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour.
Package C: For $19.95 per month for unlimited access is provided.
Write a program that calculates a customer’s monthly bill. It should ask which package the customer has purchased and how many hours were used. It should then display the total amount due.
Get the above part to work first. Use the following data to test your program:
C 20
A 8
A 30
B 20
B 35
Now, we need a little more information. Modify the above program so that it also displays how much money Package A customers would save if they purchased packages B or C, and how much money Package B customers would save if they purchased Package C. If there would be no savings, no message should be printed.
Hint: Write two functions ‘SavingsOnB’ and ‘SavingsOnC’. When calculate Package A, you will then call both functions. The functions will print out the savings or the function will print nothing.
Same for Package B, call SavingsOnC.
Explanation / Answer
please rate - thanks
should be self explanatory, if not message me
before modification
#include <iostream>
using namespace std;
int main()
{int hours;
char pack;
double tot;
cout<<"Make a Selection ";
cout<<"(A)Package A ";
cout<<"(B)Package B ";
cout<<"(C)Package C ";
cout<<"Enter your selection: ";
cin>>pack;
cout<<"Enter hours: ";
cin>>hours;
if(hours>744)
cout<<"That's more hours then in a month!! ";
else
{switch(pack)
{case 'A': if(hours<10)
tot=9.95;
else
tot=9.95+(hours-10)*2;
break;
case 'B': if(hours<20)
tot=14.95;
else
tot=14.95+(hours-20);
break;
case 'C': tot=19.95;
}
}
cout<<"Monthly Bill: $"<<tot<<endl;
system("pause");
return 0;
}
------------------------------
after modification (didn't need or use the hint, did it my own way), message me if need to use the functions. but this is from chapter 4, where functions are later in the book
#include <iostream>
using namespace std;
int main()
{int hours;
char pack;
double totA,totB,totC;
cout<<"Make a Selection ";
cout<<"(A)Package A ";
cout<<"(B)Package B ";
cout<<"(C)Package C ";
cout<<"Enter your selection: ";
cin>>pack;
cout<<"Enter hours: ";
cin>>hours;
if(hours>744)
cout<<"That's more hours then in a month!! ";
else
{ if(hours<10)
totA=9.95;
else
totA=9.95+(hours-10)*2;
if(hours<20)
totB=14.95;
else
totB=14.95+(hours-20);
totC=19.95;
}
switch (pack)
{case 'A':cout<<"Monthly Bill: $"<<totA<<endl;
cout<<"if had chosen package B would have saved $"<<totA-totB<<endl;
cout<<"if had chosen package C would have saved $"<<totA-totC<<endl;
break;
case 'B':cout<<"Monthly Bill: $"<<totB<<endl;
cout<<"if had chosen package C would have saved $"<<totB-totC<<endl;
break;
case 'C':cout<<"Monthly Bill: $"<<totC<<endl;
break;
}
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.