# How to Develop Cellular Telephone Bill Calculator? Write a program that will generate a cellular telephone bill, accept payment and instruct cashier how to give change. The amount owed is based on the number of minutes used. Customers are charged at a rate of  \$0.20 per minute.

Instructions:

1. Prompt user for the customer’s name, street address, city, state, zip code and number of minutes used.
1. Calculate and display a telephone bill with all information specified in the Sample Output on page 2.
2. After displaying the telephone bill, prompt user for the amount of money received from the customer. The user should supply the amount given in pennies, for example 275 instead of 2.75.
1. Calculate the amount of change owed and display the number of dollars, quarters, dimes, nickels, and pennies that the customer should receive.
2. Your program’s output should be formatted in the same manner as the Sample Output on page 2.
1. Bonus Pts. After completing all instructions above, add code to randomly generate the customer’s payment. That number should be an integer. Use the number for the payment rather than the one received from the user (overwrite the value stored in your payment variable with the random number). Each time the program is run, a different random number should be generated for the payment. You must follow all these instructions to receive full credit.

## Solution:

#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;

int main()
{
string name, address; // Declearing name and address using string because the intput has spaces
string city, state; // Declearing city and state using string because the intput is names
int zip_code; // Declearing zipcode using int because it is a number
int mintues_used; // Declearing mintues used using int because it is a number
double amount_owed; // Declearing amount owed using doible because the number has points
int amount_received; // Declearing amount received using int because it is gonna be pennies
int change; // Declearing change using int because it is a number
int x1, x2, x3, x4, x5;// These represnt the dollars, quarters, dimes, nickels, and pennies
char letter; // Declearing the letter
int amount_owed1; // Declearing the second amount in order to calculate it in pennies
const double base_cost = 10; // Declearing the base cost which is 10 dollars
// inputs and process

do {
cout << ” Welcome to the Cellular Telephone System” << endl << endl;
cout << “1 – Process Telephone Bill” << endl;
cout << “2 – Translate Phone Word” << endl ;
cout << “3 – Process a Data File” << endl ;
cout << “4 – Quit” << endl << endl;
cout << “Enter your choice: “;
{
cout << “Enter the name of the customer: “;
getline (cin, name);
cout << “Enter street address: “;
cout << “Enter city: “;
cin >> city;
cout << “Enter state: “;
cin >> state;
cout << “Enter zip code: “;
cin >> zip_code;
cout << “Enter the number of minutes used: “;
cin >> mintues_used;

if ( mintues_used >=0 && mintues_used <= 50)
{

amount_owed = base_cost;

cout << setprecision(2) << fixed;
cout << name << endl;
cout << city << “, ” << state << ” ” << zip_code << endl;
cout << “Amount Owed: \$” << amount_owed << endl;

cout << “Enter the amount recived from customer: “;

amount_owed1 = amount_owed*100; //This how to accepts the amount received in pennies or cents

{

x1 = change/100;
change = change%100;
x2 = change/25;
change = change%25;
x3 = change/10;
change = change%10;
x4 = change/5;
change = change%5;
x5 = change/1;

// outputs

cout << “Denomination Number” << endl;
cout << “———- ———” << endl;

cout << setw (5) << right << ” Dollars ” << right << x1 << endl;
cout << setw (5) << right << ” Quarters ” << right << x2 << endl;
cout << setw (5) << right << ” Dimes ” << right << x3 << endl;
cout << setw (5) << right << ” Nickels ” << right << x4 << endl;
cout << setw (5) << right << ” Pennies ” << right << x5 << endl;
return 0;
}
{
cout << “The amount received is smaller than the amount owed, program will end.” << endl;
return 0;
}
return 0;
}
if (mintues_used > 50)
{
amount_owed = base_cost+(mintues_used-50)*0.20;

cout << setprecision(2) << fixed;
cout << name << endl;
cout << city << “, ” << state << ” ” << zip_code << endl;
cout << “Amount Owed: \$” << amount_owed << endl;

cout << “Enter the amount recived from customer: “;

amount_owed1 = amount_owed*100; //This how to accepts the amount received in pennies or cents

{

x1 = change/100;
change = change%100;
x2 = change/25;
change = change%25;
x3 = change/10;
change = change%10;
x4 = change/5;
change = change%5;
x5 = change/1;

// outputs

cout << “Denomination Number” << endl;
cout << “———- ———” << endl;

cout << setw (5) << right << ” Dollars ” << right << x1 << endl;
cout << setw (5) << right << ” Quarters ” << right << x2 << endl;
cout << setw (5) << right << ” Dimes ” << right << x3 << endl;
cout << setw (5) << right << ” Nickels ” << right << x4 << endl;
cout << setw (5) << right << ” Pennies ” << right << x5 << endl;
return 0;
}
{
cout << “The amount received is smaller than the amount owed, program will end.” << endl;
return 0;
}
}
}
{
cout<<“Thank you. Closing program”;
exit(1);
}
{int counter = 0;int totalbill = 0;
string getcontent;
ifstream openfile (“TelephoneData.txt”);
if(openfile.is_open())
{
while(! openfile.eof())
{

counter++;
getline(openfile, getcontent);
cout << getcontent << endl;
if(getcontent.empty()){
counter = 0;
}
if(counter == 6){

totalbill += atoi(getcontent.c_str());

counter= 0;
}
}
cout<<“The total cost of all the telephone bills is “<< totalbill << endl <<endl;
}

}
{
cout << “Enter a single letter: “;
cin >> letter;
switch (letter)
{
case ‘A’:
case ‘a’:
case ‘B’:
case ‘b’:
case ‘C’:
case ‘c’:
cout << “The cooresponding phone digit is 2.” << endl;
break;
case ‘D’:
case ‘d’:
case ‘E’:
case ‘e’:
case ‘F’:
case ‘f’:
cout << “The cooresponding phone digit is 3.” << endl;
break;
case ‘G’:
case ‘g’:
case ‘H’:
case ‘h’:
case ‘I’:
case ‘i’:
cout << “The cooresponding phone digit is 4.” << endl;
break;
case ‘J’:
case ‘j’:
case ‘K’:
case ‘k’:
case ‘L’:
case ‘l’:
cout << “The cooresponding phone digit is 5.” << endl;
break;
case ‘M’:
case ‘m’:
case ‘N’:
case ‘n’:
case ‘O’:
case ‘o’:
cout << “The cooresponding phone digit is 6.” << endl;
break;
case ‘P’:
case ‘p’:
case ‘Q’:
case ‘q’:
case ‘R’:
case ‘r’:
case ‘S’:
case ‘s’:
cout << “The cooresponding phone digit is 7.” << endl;
break;
case ‘T’:
case ‘t’:
case ‘U’:
case ‘u’:
case ‘V’:
case ‘v’:
cout << “The cooresponding phone digit is 8.” << endl;
break;
case ‘W’:
case ‘w’:
case ‘X’:
case ‘x’:
case ‘Y’:
case ‘y’:
case ‘Z’:
case ‘z’:
cout << “The cooresponding phone digit is 9.” << endl;
break;
default:
cout << “The choice has to be a single letter. Program will terminate. ” << endl;

}
}
else
{
cout << menuChoice << ” is not a valid choice.” << endl;

}
}