State sales tax is 7% and a fixed monthly “Connection Fee” charge of $1.99 is assessed on all plans.
There is no tax on the connection fee.
Your program should ask which package the customer has purchased and how many text messages were used during the month. It should then display the total amount due.
2. Run your program to make sure everything is working at this point.
3. Then, your program should ask the user whether they want to check other packages (using a while loop shown below). The following is a sample output (and matching while loop structure):
|
… char checkPackage = 'Y'; … while(checkPackage == 'Y') { … // ask user inputs & … // calculate & display the bill cout << "Do you want to check out another package (Y, N)? "; cin >> checkPackage; } |
|
(Sample output) What package did you purchase (A, B, C)? B How many messages did you send this month? 243 Your bill is: $22.59 Do you want to check out another package (Y, N)? Y What package did you purchase (A, B, C)? C How many messages did you send this month? 243 Your bill is: $23.34 Do you want to check out another package (Y, N)? N |
4. Be sure to debug and test your program with several different inputs.
5. Turn in your program – Close your project (Close à Close solution OR exit Visual Studio) and turn in one copy of the.cpp file. If you want to do the Bonus, you will need to work on the same source code (i.e., .cpp file) and turn in the revised one.
6. Bonus (1 point): If you finish early, modify your program to include input validations for the package and for the number of text messages. For example, your program should only consider “A”, “B”, or “C” for the package input and a positive number for the number of the messages input. When an invalid input is given, your program should display an error message and skip the bill calculation.
|
(Sample output) What package did you purchase (A, B, C)? B How many messages did you send this month? -15 Invalid number of messages!!! Do you want to check out another package (Y, N)? Y What package did you purchase (A, B, C)? C How many messages did you send this month? 243 Your bill is: $23.34 Do you want to check out another package (Y, N)? N |
|
(Sample output) What package did you purchase (A, B, C)? H Invalid package!!! Do you want to check out another package (Y, N)? Y What package did you purchase (A, B, C)? C How many messages did you send this month? 243 Your bill is: $23.34 Do you want to check out another package (Y, N)? N |
Sample Code:
#include<iostream>
using namespace std;
int main(){
char package;
int messages;
float cost;
char checkPackage='Y';
while(checkPackage == 'Y'){
cout<<"What package did you purchase (A, B, C)?";
cin>>package;
if(package ==
'A' || package=='B' || package=='C'){
cout<<"How many messages did you send this
month?";
cin>>messages;
if(messages>=0){
cost=0.0;
if(package=='A'){
cost =
9.95;
if(messages>100){
cost+=(messages-100)*0.15;
}
}
if(package=='B'){
cost =
14.95;
if(messages>200){
cost+=(messages-200)*0.10;
}
}
if(package=='C'){
cost =
19.95;
}
cost*=1.07;
cost+=1.99;
cout<<"Your bill is:
$"<<cost<<endl;
}
else{
cout<<"Invalid number
of messages!!!"<<endl;
}
}
else{
cout<<"Invalid
package!!!"<<endl;
}
cout <<
"Do you want to check out another package (Y, N)? ";
cin >>
checkPackage;
}
return 0;
}
Output:
What package did you purchase (A, B, C)?B
How many messages did you send this month?-15
Invalid number of messages!!!
Do you want to check out another package (Y, N)? Y
What package did you purchase (A, B, C)?B
How many messages did you send this month?243
Your bill is: $22.5875
Do you want to check out another package (Y, N)? Y
What package did you purchase (A, B, C)?C
How many messages did you send this month?243
Your bill is: $23.3365
Do you want to check out another package (Y, N)? N
Write a complete C++ program that creates a monthly bill for the text messaging. Your cell...
Write a program in c++ for An electric company came out with a residential rate schedule in your state. You are asked to write a program that will compute the customer’s electric bill. Program will prompt month number and Kilowatt hour used. Sample Input Screen: Enter the month (1 - 12) : Kilowatt hours used : The electric bill is computed using the following method: There is a flat service charge of $15.31...
write in C++ Problem 1: Mobile Service Provider A cell phone service provider has three different subscription packages for its customers. Package A: For $39.99 per month 450 minutes are provided. Additional minutes are $0.45 per minute. Package B: For $59.99 per month 900 minutes are provided. Additional minutes are $0.40 per minute. Package C: For $69.99 per month unlimited minutes provided. Write a program that calculates a customer’s monthly bill. It should ask which package the customer has purchased...
C Programming Quesition (Structs in C): Write a C program that prompts the user for a date (mm/dd/yyyy). The program should then take that date and use the formula on page 190 (see problem 2 in the textbook) to convert the date entered into a very large number representing a particular date. Here is the formula from Problem 2 in the textbook: A formula can be used to calculate the number of days between two dates. This is affected by...
Show Me The Money. (15 points) Write a C++ program that calculates how much a person earns in a month if the salary is one penny the first day, two pennies the second day, four pennies the third day, and so on, with the daily pay doubling each day the employee works. The program should ask the user for the number of days the employee worked during the month and should display a table showing how much the salary was...
Write a C++ program that prompts a user to enter a temperature in Fahrenheit as a real number. After the temperature is entered display the temperature in Celsius. Your program will then prompt the user if they want to continue. If the character n or N is entered the program will stop; otherwise, the program will continue. After your program stops accepting temperatures display the average of all the temperatures entered in both Fahrenheit and Celsius. Be sure to use...
Q2.1) Write a program to calculate phone bill of the user. The rule to calculate bill is given as follows: • You should ask the option to the user at first. If the phone bill will be calculated with internet connection option, user must enter 1, otherwise user must enter O. Do all necessary controls and take the number from the user until the user enters one of the correct options. (1 or 0). • Design 2 different methods. Both...
Write a complete C program that inputs a paragraph of text and prints out each unique letter found in the text along with the number of times it occurred. A sample run of the program is given below. You should input your text from a data file specified on the command line. Your output should be formatted and presented exactly like the sample run (i.e. alphabetized with the exact spacings and output labels). The name of your data file along...
Write python program using IDLE Write a full program that asks the user to enter his/her name then repeatedly ask to enter the temperature in Fahrenheit and convert it to Celsius, the program should then prompt the user if he/she wants to continue or exit the program. The formula for the conversion is: °C = (°F - 32) x 5/9 The program should use a function for the conversion. An Example of a sample run should appear on the screen...
Using Java how would I write a program that reads and writes from binary or text files and gives me an output similar to this? Example Output: --------------------Configuration: <Default>-------------------- Enter the file name: kenb Choose binary or text file(b/t): b Choose read or write(r/w): w Enter a line of information to write to the file: lasdklj Would you like to enter another line? Y/N only n Continue? (y/n)y Enter the file name: kenb Choose binary or text file(b/t): b Choose...
Bill and Tip Calculator Write a C program to generate a receipt for a restaurant. Your application should allow the user to enter the bill amount and allow them to decide if they would like to leave a 15 percent tip or not. ▪ Do not allow the user to enter a negative value for the bill. ▪ Display the bill amount, tax amount, tip amount, and total amount. ▪ To calculate the tip, multiply the bill amount by 0.15....