Suppose that billingAmount is a double variable, which denotes the amount you ne
ID: 3685676 • 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 billingAmount and less than 50% of the billingAmount, the pen 10% of the balance; otherwise, the penalty is 20% of the balance. Design 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>
using namespace std;
int main(){
double billingAmount;
cout<<"Enter billing amount: ";
cin>>billingAmount;
double yourPay;
cout<<"How much you are paying: ";
cin>>yourPay;
double yourCredit;
if(yourPay >= billingAmount){
double temp = billingAmount*0.1;
if(temp > 10)
yourCredit = 10;
else
yourCredit = temp;
cout<<"Your remaining balance: 0"<<endl;
cout<<"Your credit amount : "<<yourCredit<<endl;
}
else if(yourPay >= (billingAmount*0.5)){
double penality = (billingAmount-yourPay)*0.05; // 5%
cout<<"Your remaining balance: "<<(billingAmount-yourPay)<<endl;
cout<<"Your penalty amount: "<<penality<<endl;
}
else if(yourPay >= (billingAmount*0.2)){
double penality = (billingAmount - yourPay)*0.1;
cout<<"Your remaining balance: "<<(billingAmount-yourPay)<<endl;
cout<<"Your penalty amount: "<<penality<<endl;
}
else{
double penality = billingAmount*0.2;
cout<<"Your remaining balance: "<<(billingAmount-yourPay)<<endl;
cout<<"Your penalty amount: "<<penality<<endl;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.