Telephone Bill Project: C++ -


alright, have edited of code, question how calculates right final total? working on regular service, , want subtract 50 free minutes first, add minutes user has overused, multiply minutes $0.20 , make finaltotal. , if have more mistakes please tell me. know have made lot of mistakes, sorry! have project do, , here requested functionalities list:

  • prompts user enter account number, service code, , number of minutes service used.

    • regular: values “r” , “r”:

      • $10.00/month
      • first 50 min. free
      • charges on 50 min. $0.20 per min.
    • premium: values “p” , “p”:

      $25.00/month plus:

      • calls between 6 - 18 first 75 min free, after they’re $0.10 per min
      • calls between 18 - 6 first 100 min free, after they’re $0.05 per min
  • if other character used display error message

  • calculate total , print bill (display out)

this code:

#include <iostream>  using namespace std; int main() { // variables // int accnum, minnum, minnumm; double total, finaltotal, grandtotal, finaltotall; char scode;  cout << "hello, thank paying phone bill." << ends; cout << endl; cout << endl;  cout << "please enter account number: "; cin >> accnum ; //enter number  cout << "please enter service code (r regular service or p premium service): "; cin >> scode ;  //enter r or r regular service , p or p premium service          ////////////// regular service //////////////  if (scode == 'r' || scode == 'r') {     // values regular service     cout << "this service provides 50 minutes phone calls 50 minutes free $10.00 month, , charge $0.20 every minute on 50 minutes." << endl;     cout << "how many minutes have used up?: ";     cin >> minnum;     if (minnum > 50) {         total = minnum * .20;         finaltotal = total + 10;         cout << "you have made phone calls on 50 minutes, total " << finaltotal << "." << endl;         cout << "your account number " << accnum << " , regular service. have used " << minnum << "/50 minutes. total $" << finaltotal << " . thank time." << endl;    //displays acc. #, type of service, # of min phone service used, , amount due user         cout << endl;     } else {         cout << "you have not made phone calls on 50 minutes, total $" << finaltotal << "." << endl;         cout << "your account number " << accnum << " , regular service. have used " << minnum << "/50 minutes. total $" << finaltotal << " . thank time." << endl; //displays acc. #, type of service, # of min phone service used, , amount due user     }         ////////////// premium service //////////////  } else if (scode == 'p' || scode == 'p') {  //values premium service     cout << "this service provides first 75 minutes phone calls 6:00 - 18:00, , charge $0.10 every minute over. first 100 minutes phone calls 18:00 - 6:00 free, , charge $0.05 every minute over." << endl;     cout << "how many minutes have used between 6:00 - 18:00? ";    //time between 6am - 6pm     cin >> minnumm;         if (minnumm > 75) {                  //if # of minutes on 75             total = minnumm * .10;           //then multiplies total * $.10             finaltotall = total + 25;   //then adds $10/month             cout << "you have made phone calls on 75 minutes, total $" << finaltotall << "." << endl;         } else {             cout << "how many minutes have used between 18:00 - 6:00? ";  }   //time between 6pm - 6am             cin >> minnum;         if (minnum > 100) {                 //if # of minutes on 100             total = minnum * .05;           //then multiplies total * $.05             finaltotal = total + 25;             //then adds $25/month             cout << "you have made phone calls on 100 minutes, total $" << finaltotal << "." << endl;              grandtotal = finaltotall + finaltotal;  //calculates both 6am-6pm , 6pm-6am totals             cout << "your account number " << accnum << " , premium service. have used " << minnumm << "/75 minutes 6:00-18:00. have used" << minnum << "/100 18:00-6:00. total $" << grandtotal << " . thank time." << endl; //displays acc. #, type of service, # of min phone service used, , amount due user         } else {             cout << "you have not made phone calls on 100 minutes, total $" << finaltotal << "." << endl;             cout << "your account number " << accnum << " , premium service. have used " << minnumm << "/75 minutes 6:00-18:00. have used " << minnum << "/100 18:00-6:00. total " << grandtotal << " . thank time." << endl;             cout << endl;             cout << endl; } //displays acc. #, type of service, # of min phone service used, , amount due user          ////////////// if typed in letter other r, r, p, p //////////////  } else {        //if user doesn't type p or r, error message     cout << "sorry, service not exist. please try again." << endl;     cout << endl; }   system("pause"); return 0; 

}

as far can see (and people in follow-up answers might find more errors), glaring issue have used and operator instead of or operator.

this statement:

if (scode == 'r' && scode == 'r') {     // values regular service 

should be:

if (scode == 'r' || scode == 'r') {     // values regular service 

similarly, statement:

if (scode == 'p' && scode == 'p') {  //values premium service 

should be:

if (scode == 'p' || scode == 'p') {  //values premium service 

a variable can't match 2 different values @ same time, if blocks never entered when using && instead of ||.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -