Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ question A third-grade teacher at Plano Elementary School wants a program th

ID: 3672630 • Letter: C

Question

C++ question

A third-grade teacher at Plano Elementary School wants a program that allows a student to enter the amount of money a customer owes and the amount of money the customer paid. The program should calculate and display the amount of change, as well as how many dollars, quarters, dimes, nickels, and pennies to return to the customer. Display an appropriate message when the amount paid is less than the amount owed

desk check

amount owed amount paid

75.34               80

39.67               50

10.55               9.75

#include <iostream>
#include <iomanip>
using namespace std;

int main()

{
   //declare variables
   double amountPaid = 0.0;
   double amountOwed = 0.0;
   double amountChange = 0.0;
   const double dollars= 1.0;
   const double quarters= 0.25;
   const double dimes = 0.1;
   const double nickles = 0.05;
   const double pennies = 0.01;
   int dollarsNeeded = 0;
   int quartersNeeded = 0;
   int dimesNeeded = 0;
   int nicklesNeeded = 0;
   int penniesNeeded = 0;
   double negativeAmount = 0.0;
   //enter input items

   cout << " Amount of money customer owed:";
   cin >> amountOwed;
  
   cout << " Amount of money customer paid:";
   cin >> amountPaid;

   //calculations

   amountChange = (amountPaid - amountOwed);
   dollarsNeeded = amountChange / dollars;
   quartersNeeded = (amountChange - dollarsNeeded) / quarters;
   dimesNeeded = (amountChange - dollarsNeeded - quartersNeeded* quarters) / dimes;
   nicklesNeeded = (amountChange - dollarsNeeded - quartersNeeded* quarters- dimesNeeded* dimes) / nickles;
   penniesNeeded = (amountChange - dollarsNeeded - quartersNeeded* quarters -dimesNeeded* dimes- nicklesNeeded* nickles) / pennies;
  
   //Output
   if (amountPaid >= amountOwed)
   {
      
       cout << " Please give customer:" << amountChange << endl;
       cout << " Amount of dollars:" << dollarsNeeded << endl;
       cout << " Amount of quarters:" << quartersNeeded << endl;
       cout << " Amount of dimes:" << dimesNeeded << endl;
       cout << " Amount of nickles:" << nicklesNeeded << endl;
  
       cout << " Amout of pennies:" << penniesNeeded << endl;

   }
   else
   {
       negativeAmount = (amountOwed - amountPaid);
       cout << "You still owe:" << negativeAmount << endl;
   }
       system("pause");
        return 0;
}

I'm short one penny. please advise. Thank you

Explanation / Answer

// This program allows a student to enter the amount of money a customer // owes and the amount of money the customer paid #include #include using namespace std; int main() { double borrowed, paid, owed; cout > borrowed; cout > paid; owed = borrowed - paid; if (owed
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote