subject

Need this java code its on zybooks. Given two integers as user inputs that represent the number of drinks to buy and the number of bottles to restock, create a VendingMachine object that performs the following operations: Purchases input number of drinks

Restocks input number of bottles

Reports inventory

The vending machine is found in VendingMachine. java. A VendingMachine's initial inventory is 20 drinks.

Ex: If the input is:

5 2

the output is:

Inventory: 17 bottles.

The file that comes with it:

// simulates a simple vending machine with operations to purchase drinks and check inventory.

public class VendingMachine {

// number of bottle in stock

private int bottles;

// initial inventory is 20

public VendingMachine(){

bottles = 20;

}

public void purchase(int amount){

bottles = bottles - amount;

}

public int getInventory(){

return bottles;

}

public void restock(int amount){

bottles = bottles + amount;

}

public void report(){

System. out. println("Inventory: " + bottles + " bottles");

}

}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 04:31
Q13 what function does a security certificate perform? a. creates user accounts b. scrambles data c. identifies users d. creates password policies e. provides file access
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. andy received a potentially infected email that was advertising products. andy is at risk of which type of security threat? a. spoofing b. sniffing c. spamming d. phishing e. typo-squatting
Answers: 2
question
Computers and Technology, 23.06.2019 18:30
How often does colleges update the cost of attendance on their website? . a)every two years b) every four years c) every year d) every semester
Answers: 1
question
Computers and Technology, 24.06.2019 01:30
Hazel has just finished adding pictures to her holiday newsletter. she decides to crop an image. what is cropping an image?
Answers: 1
You know the right answer?
Need this java code its on zybooks. Given two integers as user inputs that represent the number of d...
Questions
question
Mathematics, 05.05.2020 11:29
question
Mathematics, 05.05.2020 11:29
question
Mathematics, 05.05.2020 11:29
Questions on the website: 13722361