In: Computer Science
Problem: Your have been asked by a cell phone service provider to write a program that will calculate the amount of a customer’s monthly bill. Write a C++ program that will calculate the amount of the bill given the number of lines and the amount of minutes used during the month. Unlimited texting is also offered. '
The cellular service provider offers the following options and pricing: One line for $6/month base cost. Two lines for $12/month base cost.
The voice rates are as follows:
• No minutes: $0
• 1-400 minutes: $9 total
• 401-800 minutes: $16 total
• over 800 minutes: $16 + 1.9 cents/minute over 800 Unlimited texting is $5 extra.
Input: The program should ask the user if they have (A) one line or (B) two lines. Then the program should ask the user to input the number of minutes used in the month (no fractional amounts) Then the program should ask if the user has unlimited text messages (Y or N).
For the first two input values, use an if statement to perform input validation. The user should select only A, or B for the number of lines, and the minutes should be between 0 and 44640 (inclusive).
If either input is invalid, the program should ask the user to reenter the value (but only once, no looping).
Do not validate the response to the last question. 1 Processing: Compute the amount of the monthly bill according to the descriptions above.
If the user answered ‘y’ or ‘Y’ to the last question, your program should add $5 to the bill.
Output: Display the amount of the monthly bill with a dollar sign and formatted to 2 decimal places.
Here are 5 different sample executions of the program: How many lines: A. One line B. Two lines A Enter the total number of minutes used during the month: 100 Unlimited text messages? (Y/N): N The amount due for the month is $15.00
How many lines: A. One line B. Two lines B Enter the total number of minutes used during the month: 750 Unlimited text messages? (Y/N): Y The amount due for the month is $33.00
How many lines: A. One line B. Two lines A Enter the total number of minutes used during the month: 850 Unlimited text messages? (Y/N): Y The amount due for the month is $27.95
How many lines: A. One line B. Two lines A Enter the total number of minutes used during the month: 803 Unlimited text messages? (Y/N): y The amount due for the month is $27.06 2 How many lines: A. One line B. Two lines C Please enter A, or B: A Enter the total number of minutes used during the month: 1234567 Please enter a number between 0 and 44640 for the minutes: 500 Unlimited text messages? (Y/N): n The amount due for the month is $22.00
If you have any doubts, please give me comment...
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int total_mins;
char type, isUnlimited;
double bill;
cout<<"Display the amount of the monthly bill with a dollar sign and formatted to 2 decimal places. Here are 5 different sample executions of the program:"<<endl;
cout<<"How many lines: "<<endl;
cout<<"A. One line"<<endl;
cout<<"B. Two lines"<<endl;
cin>>type;
if(type!='A' && type!='B'){
cout<<"Please enter A, or B: ";
cin>>type;
}
cout<<"Enter the total number of minutes used during the month: ";
cin>>total_mins;
if(total_mins<0 &&total_mins>44640){
cout<<"Please enter a number between 0 and 44640 for the minutes:";
cin>>total_mins;
}
cout<<"Unlimited text messages? (Y/N): ";
cin>>isUnlimited;
if(type=='A')
bill += 6;
else
bill += 12;
if(total_mins==0)
bill += 0;
else if(total_mins<=400)
bill += 9;
else if(total_mins<=800)
bill += 16;
else
bill += 16 + (total_mins-800)*0.019;
if(isUnlimited=='Y' or isUnlimited=='y')
bill += 5;
cout<<setprecision(2)<<fixed;
cout<<"The amount due for the month is $"<<bill<<endl;
return 0;
}