IDCor Internet Service provides their customers three different Internet plans I
ID: 3687632 • Letter: I
Question
IDCor Internet Service provides their customers three different Internet plans In which customers can choose a package that suite them best. IDCor Internet service plans are as follows: Package Q: 100 AED/month Includes 10GB limit. Additional per 1 GB cost is 25 AED. Package G: 150 AED/month Includes 150 GB limit. Additional cost Is 30AED per 1G8. Package Z: 250 AED/month includes unlimited usage. Write a program that prompts the user for a customer first and last name, account number, internet package they use, and the number of gigabytes used a month. With that Information, calculate their monthly bill and display it to them. After the Invoice Is printed, the program shall ask the user if they need to enter the Information for another account or if they wish to exit. If they select the option "Yes", allow the user to enter ONLY an account number, the internet usage, and the package code Q, G, or Z (accept also small letters q, g, or z for the package code) and calculate the bill for the other account number. The program shall continuously run until the user select the option "No" for not entering another account number. In this case, the program will exit. Functions Requirements: calculate_cost function must be defined as specified below. The function takes In the data used, and package selection as input parameters and returns the cost based on the user usage printlnvoice function must be defined as specified below. The function takes in the first name, last name, account number, minutes, data used, package and cost, and formats the invoice and outputs it to the screen for the user. create the proper function calls within your program to solve the required problemExplanation / Answer
#include <iostream>
#include <string>
using namespace std;
double calculate_cost(double dataused, char package) {
double cost = 0;
if (package == 'q' || package == 'Q') {
cost = 100;
if (dataused > 10)
cost += (dataused - 10) * 25;
} else if (package == 'g' || package == 'G') {
cost = 150;
if (dataused > 150)
cost += (dataused - 150) * 30;
} else if (package == 'z' || package == 'Z') {
cost = 250;
}
return cost;
}
void printinvoice(string fname, string lname, string accNo, double dataused,
char package, double cost) {
cout << " " << fname << " " << lname << " Invoice (" << accNo
<< ")" << endl;
cout
<< "----------------------------------------------------------------------"
<< endl;
cout << "Internet usage in gigabytes: " << dataused << endl;
cout << "You are on package: " << package << endl;
cout << " Total balaance: " << cost << " AED" << endl;
cout << " Thank you for being a customer with IDCor Internet service"
<< endl;
}
int main() {
string fName, lName, accNo;
char package;
double gb;
cout << "Enter First Name:" << endl;
cin >> fName;
cout << "Enter Last Name:" << endl;
cin >> lName;
cout << "Enter account number:" << endl;
cin >> accNo;
cout << "Enter your internet package (q/g/z):" << endl;
cin >> package;
cout << "Enter usage in gigabytes:" << endl;
cin >> gb;
double cost = calculate_cost(gb, package);
printinvoice(fName, lName, accNo, gb, package, cost);
int option;
do {
cout << " Would you like to enter another account number (1 - Yes , 2 - No): " << endl;
cin >> option;
if (option == 1) {
cout << "Enter account number:" << endl;
cin >> accNo;
cout << "Enter your internet package (q/g/z):" << endl;
cin >> package;
cout << "Enter usage in gigabytes:" << endl;
cin >> gb;
printinvoice(fName, lName, accNo, gb, package, cost);
} else if (option == 2)
break;
else
cout << "Invalid option" << endl;
} while (option != 2);
return 0;
}
-------------output--------------------
Enter First Name:
John
Enter Last Name:
Kerry
Enter account number:
AP24494994
Enter your internet package (q/g/z):
q
Enter usage in gigabytes:
14
John Kerry Invoice (AP24494994)
----------------------------------------------------------------------
Internet usage in gigabytes: 14
You are on package: q
Total balaance: 200 AED
Thank you for being a customer with IDCor Internet service
Would you like to enter another account number (1 - Yes , 2 - No):
1
Enter account number:
EJE33333322
Enter your internet package (q/g/z):
g
Enter usage in gigabytes:
69
John Kerry Invoice (EJE33333322)
----------------------------------------------------------------------
Internet usage in gigabytes: 69
You are on package: g
Total balaance: 200 AED
Thank you for being a customer with IDCor Internet service
Would you like to enter another account number (1 - Yes , 2 - No):
2