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
Becky is preparing a document for her environmental studies project. She wants to check her document for spelling and grammar er
Sunny_sXe [5.5K]
If it's MS Word (it probably is), then it's Alt + F7
7 0
2 years ago
Read 2 more answers
Rohan is creating a presentation with at least 50 slides. He wants the slides to use a consistent layout and formatting. Which o
erma4kov [3.2K]

The parts of the presentation that he should design first is Slide master

Slide master is a slide that enables you  to do the following:

•Modify your presentation to suit your taste

•It enables you to make  a partial or minor change  on the slide layout of your presentation

•Slide master  help you to  create a perfect and special  presentation.

•With Slide master  you can easily modify your slide text color.

Inconclusion The parts of the presentation that he should design first is Slide master.

Learn more about Slide master here:

brainly.com/question/12600334

4 0
2 years ago
The geographic coordinate system is used to represent any location on Earth as a combination of latitude and longitude values. T
Pachacha [2.7K]

Answer:

Here is the script:  

function dd = functionDMS(dd)  

prompt= 'Enter angle in DD form ';

dd = input(prompt)

while (~checknum(dd))

if ~checknum(dd)

error('Enter valid input ');

end

dd = input(prompt)

end  

degrees = int(dd)

minutes = int(dd - degrees)

seconds = ( dd - degrees - minutes / 60 ) * 3600  

print degrees

print minutes

print seconds

print dd

Explanation:

The script prompts the user to enter an angle in decimal degree (DD) form. Next it stores that input in dd. The while loop condition checks that input is in valid form. If the input is not valid then it displays the message: Enter valid input. If the input is valid then the program converts the input dd into degrees, minutes and seconds form. In order to compute degrees the whole number part of input value dd is used. In order to compute the minutes, the value of degrees is subtracted from value of dd. The other way is to multiply remaining decimal by 60 and then use whole number part of the answer as minutes. In order to compute seconds subtract dd , degrees and minutes values and divide the answer by 60 and multiply the entire result with 3600. At the end the values of degrees minutes and seconds are printed. In MATLAB there is also a function used to convert decimal degrees to degrees minutes and seconds representation. This function is degrees2dms.

Another method to convert dd into dms is:

data = "Enter value of dd"

dd = input(data)

degrees = fix(dd);

minutes = dd - degrees;

seconds = (dd-degrees-minutes/60) *3600;

8 0
2 years ago
(PYTHON HOMEWORK)Given the following code snippet, which statement tests to see if all three sets are equal?:
wariber [46]

Answer:

Option D is the correct answer to the following question.

Explanation:

The following option is correct because three sets type variable i.e., "fruit", "fruit2", "fruit3" has contain the same values in it and then they ask for the option is correct if the all are equal and in the option c, there is the if statement in which check the condition if the variable "fruit" is equal to the variable "fruit2" and the variable "fruit" is equal to the variable "fruit3".

so, that' why the following option is correct.

The option A is not correct because there is no equal function in python and we use the operator == to check the condition.

The option B is incorrect because we can see that there is not equal to (!=) operator.

The option D is incorrect because we can see that there is an or operator are used which means if any of the conditions is true then, they return either the other condition is false.

8 0
2 years ago
You have installed a device at the physical layer. All of the systems you connect to this device will talk to each other at the
9966 [12]

Answer: Hub

Explanation:

Hub is a electronic and networking device that is placed in a network to maintain a common link with the multiple attached devices. Hub is situated at the physical layer of the Open systems interconnection(OSI) model.

  • Hub is used for creation of link between numerous local area network sections as it persist various ports which replicates data packet and distributes to other ports.
  • There are different types of hub for different purpose of connection such as USB hub, Ethernet hub etc.  

8 0
2 years ago
Other questions:
  • Write a method named quarterstodollars. the method should accept an int argument that is a number of quarters, and return the eq
    13·2 answers
  • One reason for using social media is to develop social and professional contacts. True or false?
    9·2 answers
  • 1. What is the global marketplace?
    11·2 answers
  • Read this excerpt from The Outsiders. Or I could have gotten one of the gang to come along, one of the four boys Darry and Soda
    6·2 answers
  • PHP is based on C rather than ______.
    5·1 answer
  • _______________ is used by a hacker to mask intrusion and obtain administrator permissions to a computer.
    7·1 answer
  • Which formula would you enter into C3, and then AutoFill into C4 through C6, to calculate the percent sales (Pct.) for the regio
    6·1 answer
  • 3.14 LAB: Simple statistics for Python
    7·1 answer
  • You work for a car rental agency and want to determine what characteristics are shared among your most loyal customers. To do th
    10·1 answer
  • Why are passive readers most likely to have difficulty focusing on a text?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!