Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MY C++ CODE: #include using namespace std; int main() { int amount; cout cout ; cin >> amount; cout 100) { cout change = quarters

image text in transcribedimage text in transcribed 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 --> 36 You entered a purchase amount of 36 cents. Your change of 65 cents is given as: quarter(s): 2 dime (s): 1 nickel(s): 1 Vending Machine Version 1 by Your Name There are 2 quarters, 2 dimes, and 1 nickel. Enter a purchase amount to - 100) --> 105 You entered a purchase amount of 105 cents. You entered an invalid amount (not between 0 and 100). Vending Machine Version 1 by Your Name There are 2 quarters, 2 dimes, and 1 nickel Enter a purchase amount 10 - 100) --> 38 You entered a purchase amount of 30 cents. Your change of 60 cents is given as: quarter(s): 2 dime(): nickel(s): 0 Vending Machine Version 1 by Your Name There are 2 quarters, 2 dimes, and 1 nickel. Enter a purchase amount to - 100) --> 25cEnter> You entered a purchase amount of 25 cents. Your change of 75 cents is given as: quarter(s): 2 dime(): nickel(s): 1 Vending Machine Version 1 by Your Name) There are 2 quarters, 2 dimes, and 1 nickel. Enter a purchase amount to - 100) --> 20-CEnter> You entered a purchase amount of 20 cents. Your change of 80 cents cannot not be processed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

What are Electrophoresis?

Answered: 1 week ago