Problem.
Hi C++ geniuses! I am stuck with this program that was assigned as a homework. I will post the question along side with my coded program. Here is the question as follows:
An Internet service provider has three different subscription packages for its 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 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.
Input Validation: Be sure the user only selects package A, B, or C. Also, the number of hours used in a month cannot exceed 744.
need the flowchart please help
Solution.
Code
#include <iostream>
#include <string>
using namespace std;
int main() {
string package;
float time;
float price;
cout << "Choose package: ";
cin >> package;
// Package validation
if ((package == "A") || (package == "B") || (package == "C")) {
cout << "The number of hours: ";
cin >> time;
// Time validation
if (time <= 744) {
// Package A
if (package == "A") {
if (time > 10) {
price = 9.95 + (time - 10) * 2;
} else {
price = 9.95;
}
// Package B
} else if (package == "B") {
if (time > 20) {
price = 14.95 + (time - 20) * 1;
} else {
price = 14.95;
}
// Package C
} else {
price = 19.95;
}
} else {
cout << "Invalid number of hours!";
}
} else {
cout << "Invalid package!";
}
cout << "Price: $" << price;
}Flowchart (http://code2flow.com/Td579h)
Result
Choose package: B
The number of hours: 22
Price: $16.95
http://www.AssignmentExpert.com/