[SOLVED] CS1570 Homework 1-The “Schmealthy” Vending Machine

30.00 $

Category: Tags: , , , , , ,
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon CS1570-HW1-main-busej2.zip (623.1 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
Rate this product

Background:

The “Schmealthy” Vending Machine It’s dierent from healthy!

In an ever changing world where everyone is focused on both eating healthy and saving money, it’s no wonder these Schmealth vending machines are popping up all over the place! Well, they will once you design them, of course. The way these machines work is simple: When a customer approaches one, the machines asks how much money they have. Then, the customer selects products until they either choose to stop, or they run out of money. The products that can be ordered, as well as their prices and corresponding buttons, are as follows:

Button

Product

Price

1

Schmapple

$1.50

2

Lightly Used Grape

$1.00

3

Scent of a Pizza

$0.50

4

Heavily Used Grape

$1.25

5

Banana?

$2.00

Once a customer has finished ordering products, output which products they bought (in ascending order of button number), the quantity of each item, and how much money they have left.

Specifications:

Program Flow:

  1. Greet the user
  2. Get how much money the user has as input
  3. Prompt user to select a product 1-5
  4. If the user has the funds to purchase it, state that the product was

    successfully purchased. If not, state that they do not have enough

    funds.

  5. Asktheuseriftheywouldliketopurchasemoreproducts(yorn)
  6. Repeat steps 3-5 if they choose y. If they choose n, output which

    products the user bought, the quantity of those products, and how much money they have remaining.

Tips:

In this assignment, you will be required to output all of your monetary values with 2 decimal places (even if it is a whole number, such as $11.00). An easy way to accomplish this is with the following lines of code:

#include <iomanip>

cout << fixed;
cout << setprecision(2);

The #include statement should go with your other #include statements, and the cout statements should go in your main function, at any point before your first cout statement for a monetary value. .

Example Output 1
(User input in red, console output in blue)

This is the Schmending Machine! How much money do you have?

37.50

Enter product selection (1-5)

3

Purchased: Scent of a pizza Keep purchasing? (y/n)
y
Enter product selection (1-5) 2

Purchased: Lightly Used Grape Keep purchasing? (y/n)
y
Enter product selection (1-5)

3

Purchased: Scent of a pizza Keep purchasing? (y/n)
n

You purchased: Lightly Used Grape – 1 Scent of Pizza – 2

You have $35.50 remaining. Have a Schmealthy day!

Example Output 2

This is the Schmending Machine! How much money do you have?

1.5

Enter product selection (1-5)

4

Purchased: Heavily Used Grape Keep purchasing? (y/n)
y
Enter product selection (1-5)

1

Not enough funds!

Keep purchasing? (y/n)

n

You purchased: Heavily Used Grape – 1

You have $0.25 remaining. Have a Schmealthy day!

  • CS1570-HW1-main-busej2.zip