• Advertisement
Sign in to follow this  

Tariff program

This topic is 4655 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

#include <iostream.h> #include <conio.h> #include <iomanip.h> int totalmins, prepaidmins, paidmins; char tariff, A, B, C, D, E, repeat;; float rental, minutescost, totalcosts; void main () { do { cout << "Welcome To Mega Phones. Please enter your tariff code" << endl; cout << endl; cout << endl; cout << " ----------------------------------------------- " <<endl; // this will out put a table on the screen for the users to see the avalible tariffs. cout << "| Tariff | Line Rental | Free Minutes |" <<endl; cout << " ----------------------------------------------- " <<endl; cout << "| A | 00.00 | 0 |" <<endl; cout << "| B | 04.00 | 50 |" <<endl; cout << "| C | 07.25 | 100 |" <<endl; cout << "| D | 12.75 | 200 |" <<endl; cout << "| E | 20.00 | 400 |" <<endl; cout << " ----------------------------------------------- " <<endl; cout << endl; cout << endl; do { //The loop wont let you continue untill you have selected an valid tariff. cout << "please enter Your Tarif code here..."; cin >> tariff; cout << endl; // Processing tariff if (tariff == 'A'){ rental = 0; prepaidmins = 0; } else if (tariff == 'B') { rental = 4.00; prepaidmins = 50; } else if (tariff == 'C') { rental = 7.25; prepaidmins = 100; } else if (tariff == 'D') { rental = 12.75; prepaidmins = 200; } else { rental = 20.00; prepaidmins = 400; } cout << endl; cout << "The rates are all the same for each tariff." << endl; cout << "this also shows the cost of your calls." << endl; cout << endl; cout << " --------------------------------------------------------------- " <<endl; cout << " |Number of minutes of calls | Call Charge per minute |" <<endl; cout << " |---------------------------------------------------------------|" <<endl; cout << " |The first 20 minutes | 0.30 |" <<endl; cout << " |The next 30 minutes | 0.25 |" <<endl; cout << " |the next 50 minutes | 0.20 |" <<endl; cout << " |Any Further minutes | 0.10 |" <<endl; cout << " --------------------------------------------------------------- " <<endl; cout << endl; do { cout << "please enter how many minutes you have used . . . " ;//This will ask the users how many minutes they have used. cin >> totalmins; cout << endl; if (totalmins <0) {cout << "Sorry. That was not a valid amount of minutes. " << endl;}// Makes sure you have entered a positive number of minutes. // Calculate paid minutes if (totalmins > prepaidmins) { paidmins = totalmins - prepaidmins; } // Calculate minutes cost if (paidmins <= 10) { minutescost = paidmins * 0.10; } else if (paidmins <= 30) { minutescost = 3.00 + (paidmins -10)* 0.2; } else { minutescost = 7.00 + (paidmins - 30) * 0.1; } // Calculate total cost totalcosts = rental + minutescost; // Output results // Display results in table cout << " " << endl; cout << "For tariff " << tariff << " and " << totalmins; cout << " minutes of call time...." << endl; cout << " " << endl; cout << "prepaid call time " << prepaidmins << " minutes" <<endl; cout << " " << endl; cout << "Call Cost " << setw(6) << char(156) << minutescost << endl; cout << "Rental " << setw(6) << char(156) << rental << endl; cout << "Total Cost " << setw(6) << char(156) << totalcosts << endl; cout << "Do you want to repeat Y or N? "; cin >> repeat;// this allows the user to repeat the process if they want. }while (repeat=='y' || repeat=='Y'); //This will repeat the process if you type y or end it if you type n } thats my code now im reciving an error called parse error at end of input on line 117, this line has nothing writern on it, weather that makes any consequense i dont know but ive fiddeled round with this for a long time and cant figure it out... can any help?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement