Here's is my C++ program exercise 4-12:
Suppose that billingAmount is adouble variable, which denotesthe amount you need to pay to thedepartment store. If you pay thefull amount, you get $10.00 or 1%of the billingAmount, whichever issmaller, as a credit on your nextbill; If you pay at least 50% of thebillingAmount, the penalty is 5%of the balance; If you pay at least20% of the billingAmount and lessthan 50% of the billingAmount,the penalty is 10% of the balance;otherwise the penalty is 20% of thebalance. Design an algorithm thatprompts the user to enter thebilling amount and the desiredpayment. The algorithm thencalculates and outputs the credit orthe remaining balance. If theamount is not paid in full, thealgorithm should also output thepenalty amount.
Now here's what I have so far:
#include #include using namespace std;//declare constant variables//define the main functionint main(){//declare the variablesdouble billingAmount;double billingPayment;double credit;double penalty;double balance;double newBalance;//Prompt the user to input the billing amount.cout < "please="" enter="" the="" billing="" amount:="">cin >> billingAmount;cout <>//Prompt the user to input the payment amount.cout <"please enter="" the="" payment="" amount:="">"please>cin >> billingPayment;cout <>cout < fixed="">< showpoint=""><>if (billingPayment == balance * 1.00)credit = billingAmount * 0.01;else if (credit >= 10.00)credit = 10.00;else if (billingPayment >= 0.50)penalty = balance * 0.05;else if (billingPayment >= 0.20 && billingPayment <>penalty = balance * 0.10;elsepenalty = balance * 0.20;newBalance = balance + penalty;cout <"the penalty="" add="" to="" your="" next="" bill="" is:="" $"="">"the>< penalty=""><>cout <"the unpaid="" balance="" including="" the="" penalty="" is:="" $"="">"the>< newbalance=""><>return 0;}I suspect that I'm missing several constant variables, or I'm not using my declared variables correctly. Can someone help me smooth out the rough edges? Thanks!
using namespace std;
//declare constant variables
//define the main functionint main(){//declare the variablesdouble billingAmount;double billingPayment;double credit;double penalty;double balance;double newBalance;
//Prompt the user to input the billing amount.cout < "please="" enter="" the="" billing="" amount:="">cin >> billingAmount;cout <>
//Prompt the user to input the payment amount.cout <"please enter="" the="" payment="" amount:="">"please>cin >> billingPayment;cout <>
cout < fixed="">< showpoint=""><>if (billingPayment == balance * 1.00)credit = billingAmount * 0.01;else if (credit >= 10.00)credit = 10.00;else if (billingPayment >= 0.50)penalty = balance * 0.05;else if (billingPayment >= 0.20 && billingPayment <>penalty = balance * 0.10;elsepenalty = balance * 0.20;
newBalance = balance + penalty;
cout <"the penalty="" add="" to="" your="" next="" bill="" is:="" $"="">"the>< penalty=""><>
cout <"the unpaid="" balance="" including="" the="" penalty="" is:="" $"="">"the>< newbalance=""><>
return 0;}
I suspect that I'm missing several constant variables, or I'm not using my declared variables correctly. Can someone help me smooth out the rough edges? Thanks!
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here