for C++ Beginner Programming Class Suppose that billingAmount is a double variab
ID: 672087 • Letter: F
Question
for C++ Beginner Programming Class
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.
Perform an analysis and design the algorithm. Then implement the code. Compile and test your code. Upload your analysis, design, and source code here.
Explanation / Answer
#include<iostream.h>
#include<conio.h>
void main()
{
double billingAmount,pay,credit,penalty,bal;
cout<<"Enter Billing Amount";
cin>>billingAmount;
cout<<"Enter Amount Payment";
cin>>pay;
bal=billingAmount-pay;
cout<<"Balance amount is "<<bal;
if(pay==billingAmount)
{
credit=pay*1/100;
cout<<"Credit for next bill "<<credit;
}
else if(pay>=(billingAmount/2))
{
penalty = bal*5/100;
cout<<"Penalty "<<penalty;
}
else
{
penalty= bal*10/100;
cout<<"Penalty "<<penalty;
}
getch();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.