Here's is my C++ program exercise 4-12: 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. Now here's what I have so far: #include <iostream>#include <iomanip> 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 << endl; //Prompt the user to input the payment amount.cout <<"Please Enter the payment amount: $";cin >> billingPayment;cout << endl; cout << fixed << showpoint << setprecision(2);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 < 0.50)penalty = balance * 0.10;elsepenalty = balance * 0.20; newBalance = balance + penalty; cout <<"The penalty add to your next bill is: $" << penalty << endl; cout <<"The unpaid balance including the penalty is: $" << newBalance << endl; 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!

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 20PE: When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making...
icon
Related questions
Question

Here's is my C++ program exercise 4-12:

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.

Now here's what I have so far:

#include <iostream>
#include <iomanip>

using namespace std;

//declare constant variables


//define the main function
int main()
{
//declare the variables
double 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 << endl;

//Prompt the user to input the payment amount.
cout <<"Please Enter the payment amount: $";
cin >> billingPayment;
cout << endl;

cout << fixed << showpoint << setprecision(2);
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 < 0.50)
penalty = balance * 0.10;
else
penalty = balance * 0.20;

newBalance = balance + penalty;

cout <<"The penalty add to your next bill is: $" << penalty << endl;

cout <<"The unpaid balance including the penalty is: $" << newBalance << endl;

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!

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning