Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MY C++ CODE: #include using namespace std; int main() { int amount; cout cout ; cin >> amount; cout 100) { cout change = quarters
MY C++ CODE:
#include using namespace std;
int main() {
int amount;
cout
cout "; cin >> amount;
cout 100) { cout
change = quarters * 25 + dimes * 10 + nickels * 5;
if (quarters
cout
}
return 0; }
So far, only the second test case works for my code. Please change my code so that all test cases work.
Please write in C++
Exercise 5 - Simple Vending Machine Version 1 - more points for this exercise Your program would read an integer value between 0 and 100 (inclusive), representing the amount of a purchase in cents from a vending machine. Produce an error message if the input value is not in that range. If the input is valid determine the amount of change that would be returned from one dollar, and print the number of quarters, dimes, and nickels. Since pennies are not available, round the changes to the nearest multiple of 5 as needed. Assume that there are exactly 2 quarters, 2 dimes, and 1 nickel in the machine. It is important to maximize the coins with the highest value first and utilize the next denomination if the current denomination is exhausted. Reject a valid purchase if it cannot be processed (1.e., not enough available coins to make the change). Follow the format below and you must plan and write down the pseudocode before attempting your code on the computer. Run the following five test cases (5 separate runs): Vending Machine Version 1 by Your Name There are 2 quarters, 2 dimes, and 1 nickel. Enter a purchase amount to - 1001 --> 36Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started