answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
statuscvo [17]
2 years ago
11

Write a program that simulates the functionality of a vending machine having the following characteristics:• The vending machine

offers 5 products• The vending machine accepts coins, 1 dollar bills, and 5 dollar bills• The change is always given in coins, with maximum possible number of coins in each value: 25, 10, 5 or 1 cent.• The selections available for user are numbers from 1 to 5.• The user enters the money – simulate the action through a loop that ends when the user enters 0. Each coin, or paper bill will be read individually.• The user makes the selection, and the machine allows a maximum 4 other selections if the amount entered doesn’t cover the price of the item.• Once an item is delivered, the machine gives the change in coins.• There is no increment for the money during one selection.• The user can stop the selection at any time by entering 0 for the product selection.• If the user chooses to cancel the selection, the machine returns the initial amount in coins.• Display the outcome of the operation for each alternative you consider possible for the vending machine.• Make sure that the machine returns the correct change at all times.
Computers and Technology
1 answer:
ValentinkaMS [17]2 years ago
5 0

Answer:

Check the explanation

Explanation:

import java.util.*;

public class VendingMachineAssignement {

   public static void main(String[] args) {

       Scanner keyboard = new Scanner(System.in);

       double item1 = 1.25;

       double item2 = .75;

       double item3 = .90;

       double item4 = .75;

       double item5 = 1.50;

       double item6 = .75;

       System.out.print("Enter an item number: ");

       int item = keyboard.nextInt();

       System.out.print("Enter the amount paid: ");

       double paid = keyboard.nextDouble();

       if (item == 2 || item == 4 || item == 6)

       {

           if (paid >= item2)

           {

               System.out.println("Thank you for buying item " + item + ", your change is $" + (paid-item2) + ". Please come again!");

           }

           if (paid < item2)

           {

               System.out.println("Please insert another " + "$" + (item2-paid));

           }

       }

       else if (item == 1)

       {

           if (paid >= item1)

           {

               System.out.println("Thank you for buying item " + item + ", your change is $" + (paid-item1) + ". Please come again!");

           }

           if (paid < item1)

           {

               System.out.println("Please insert another " + "$" + (item1-paid));

           }

       }

       else if (item == 3)

       {

           if (paid >= item3)

           {

               System.out.println("Thank you for buying item " + item + ", your change is $" + (paid-item3) + ". Please come again!");

           }

           if (paid < item3)

           {

               System.out.println("Please insert another " + "$" + (item3-paid));

           }

       }

       else if (item == 5)

       {

           if (paid >= item5)

           {

               System.out.println("Thank you for buying item " + item + ", your change is $" + (paid-item5) + ". Please come again!");

           }

           if (paid < item5)

           {

               System.out.println("Please insert another " + "$" + (item5-paid));

           }

       }

   }

}

You might be interested in
1. PLCs were originally designed as replacements for: a) microcomputers. c) analog controllers. b) relay control panels. d) digi
timama [110]

Answer:

PLCs (Programmable logic controller) were original designed as replacement for relay control panels.  Relay is another word for a switch. Relay control panels were made for the control of electronic instrumentents or devices. Later on PLCs were made to replace these timers and relay control panels. PLCs are more reliable, flexible and can work better in the harsh environmental situations then the relay control panels.

3 0
2 years ago
Seneca has just applied conditional formatting and realizes that she has made a mistake. Which action should she take to fix the
Mama L [17]

Answer:

its b

Explanation:

on edg

3 0
1 year ago
Read 2 more answers
Give a recursive (or non-recursive) algorithm to compute the product of two positive integers, m and n, using only addition and
LiRa [457]

Answer:

Multiply(m,n)

1. Initialize product=0.

2. for i=1 to n

3.      product = product +m.

4. Output product.

Explanation:

Here we take the variable "product" to store the result m×n. And in this algorithm we find m×n by adding m, n times.

6 0
2 years ago
If Maya wants to access a view that would control multiple slides within a presentation, which view should she utilize? Master v
Basile [38]

Answer:

I think it’s slide shorter view

Explanation:

6 0
2 years ago
A government agency is getting rid of older workstations. The agency will donate these workstations, along with other excess com
Basile [38]

Answer:

The answer is "Using the DoD 5220.22-M method and  Degauss media with a magnet".

Explanation:

The "DoD Standard" is a term used during the data sanitizing industry and refers to DoD 5220.22-M. The simplest ways are being used to help eliminate the previously stored data, by deleting hard disc storage facilities with the same data wherever that used a sequence of all zeros.

The sparging eliminates statistics to entirely delete the gravitational flux from electronic media. Hard drives as well as other data storage devices, for example, computer tapes, retain magnetic data. It could no longer be seen as storage after a disk is degaussed.

6 0
2 years ago
Other questions:
  • What are the possible consequences if you fail to identify system requirements correctly and completely?
    9·1 answer
  • Jimmy is preparing a slide show to teach the grade three students the importance of cleanliness. which element should he use in
    5·2 answers
  • An mp3 takes up about 16 kilobytes of memory per second of music. if you owned a one terabyte hard drive and filled it with only
    15·1 answer
  • FTP requires confirmation that a file was successfully transmitted to a client, but it has no built-in mechanism to track this i
    5·1 answer
  • A class of Students was previously defined with the following properties: a string name, an integer age, a Boolean variable indi
    14·1 answer
  • The term Electronic Privacy Information Center (EPIC) refers to a form of the digital subscriber line technology, which enables
    6·1 answer
  • (Java) Which of the following code segments correctly declare a Strings and gives it a value of "fortran".
    12·1 answer
  • Find the sum of the squares of the integers from 1 to MySquare, where MySquare is input by the user. Be sure to check that the u
    6·1 answer
  • Alice just wrote a new app using Python. She tested her code and noticed some of her lines of code are out of order. Which princ
    8·1 answer
  • Exponentiation Is a/an operater?​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!