Suppose that billingAmount is a double variable, which denotes the amount you ne
ID: 3566392 • Letter: S
Question
Suppose that billingAmount is a double variable, which denotes the
amount you need to pay to the department store. if you pay the full
amount, you get $10.00 or 1% of the billingAmount, whichever is
smaller, as a credit on your next bill; if you pay at least 50% of the
billingAmount, the penalty is 5% of the balance; if you pay at least 20%
of the billingAmount and less than 50% of the billingAmount, the
penalty is 10% of the balance; otherwise, the penalty is 20% of the balance.
Design an algorithm that prompts the user to enter the billing amount and
the desired payment. The algorithm then calculates and outputs the credit
or the remaining balance. If the amount is not paid in full, the algorithm
should also output the penalty amount.
Explanation / Answer
#include <iostream>
#include<conio.h>
using namespace std;
int main() {
// your code goes here
double billAmount,billPaid,amountCredit,billPenalty,billPercentage;
cout<< "Enter the amount to be paid for bill ";
cin >> billAmount;
cout<< "Enter the amount you want to pay for corresponding bill ";
cin >> billPaid;
if(billPaid == billAmount)
{
if(.01*billAmount<=10)
amountCredit = .01*billAmount;
else
amountCredit = 10;
cout<<"Amount Credited is "<<amountCredit<<"$"<<" ";
}
else
{
billPercentage = (billAmount/(billAmount-billPaid))*100;
if(billPercentage>=50.0)
billPenalty = .05*billAmount;
else if(20.0<=billPercentage && billPercentage<50.0)
billPenalty = .01*billAmount;
else
billPenalty = .2*billAmount;
cout<<"Bill Penalty is "<<billPenalty<<"$"<<" ";
}
getch();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.