Having a little trouble getting my code to run. Case \'b\' or \'B\' and default
ID: 646165 • Letter: H
Question
Having a little trouble getting my code to run. Case 'b' or 'B' and default work fine; however, when i type in 'r' or 'R' nothing happens besides the message (11db).
#include
#include
#include
using namespace std;
int main()
{
int accountNumber, rNumberOfPremiumChannels, bNumberOfPremiumChannels, numberOfConnections;
double rTotal, bTotal;
char customerCode;
const double rBillProcessing=4.50;
const double rBasicService=20.50;
const double rPremiumChannels=7.50;
const double bBillProcessing=15.00;
const double bBasicService=75.00;
const double bPremiumChannels=50.00;
const double connectionCost=5.00;
cout << "Please enter account number: ";
cin >> accountNumber;
cout << endl;
cout << "Please enter customer code: ";
cin >> customerCode;
cout << endl;
switch (customerCode)
{
case 'r':
case 'R':
cout << "Please enter number of premium channels: ";
cin >> rNumberOfPremiumChannels;
cout << endl;
rTotal=rBillProcessing+rBasicService+rPremiumChannels * rNumberOfPremiumChannels;
cout << "Account number: " << accountNumber << endl;
cout << "Ammount due: " << rTotal << endl;
break;
case 'b':
case 'B':
cout << "Please enter number of connections: " ;
cin >> numberOfConnections;
cout << "Please enter number of premium channels: ";
cin >> bNumberOfPremiumChannels;
if (bNumberOfPremiumChannels <= 10)
bTotal=bBillProcessing+bBasicService+bPremiumChannels * bNumberOfPremiumChannels;
else
bTotal=bBillProcessing+bBasicService+(numberOfConnections-10)+connectionCost+bPremiumChannels*bNumberOfPremiumChannels;
cout << "Account Number: " << accountNumber << endl;
cout << "Amount Due: " <
break;
default:
cout << "Invalid entry, please try again" << endl;
}
return 0;
}
Explanation / Answer
The output of first case, i.e. case
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.