Answer to Question #5070 in C++ for aymz

Question #5070
Make a program to calculate the bills of the users of a telecom company having three different categories gold, silver and copper categories. Gold category users have to pay ( w+x+y+z)* 1000 , silver cateory users have to pay ( w+x+y+z)*500 for first 200 calls and then additional 1 Rs for each additional call. Copper category users have to pay Rs 5 per call.
1
Expert's answer
2011-11-11T08:27:13-0500
#include <iostream>

using namespace std;

int main()
{
int cat, w, x, y, z, S, nCall, lp;

while (1){
system("cls");
S = 0;
cout << "1. Gold\n";
cout << "2. Silver\n";
cout << "3. Copper\n";
cout << "Select the number of category: ";
cin >> cat;

if(cat == 1){
& cout << "Enter w:";
& cin >> w;
& cout << "Enter x:";
& cin >> x;
& cout << "Enter y:";
& cin >> y;
& cout << "Enter z:";
& cin >> z;
& S = (w+x+y+z)*1000;
& cout << "User have to pay: " << S;
}

else if(cat == 2){
& cout << "Enter w:";
& cin >> w;
& cout << "Enter x:";
& cin >> x;
& cout << "Enter y:";
& cin >> y;
& cout << "Enter z:";
& cin >> z;
& cout << "How many calls did the user: ";
& cin >> nCall;
& if (nCall > 200)
S = (w+x+y+z)*500 + nCall - 200;
& else if (nCall < 200 && nCall > 0)
S = (w+x+y+z)*500;
& else
cout << "Wrong number!\n";
& cout << "User have to pay: " << S;
}

if (cat == 3){
& cout << "How many calls did the user: ";
& cin >> nCall;
& S = nCall*5;
& cout << "User have to pay: " << S;
}
cout << "\nEnter 1 to continue or 2 to exit: ";
cin >> lp;
if (lp == 2)
& break;
}

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS