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, 22.06.2019 01:30
Consider the following statements: #include #include class temporary { private: string description; double first; double second; public: temporary(string = "", double = 0.0, double = 0.0); void set(string, double, double); double manipulate(); void get(string& , double& , double& ); void setdescription(string); void setfirst(double); void setsecond(double); }; write the definition of the member function set() so that the instance variables are set according to the parameters. write the definition of the constructor so that it initializes the instance variables using the function set() write the definition of the member function manipulate() that returns a decimal number (double) as follows: if the value of description is "rectangle", it returns first * second if the value of description is "circle" it returns the area of a circle with radius first if the value of description is "cylinder" it returns the volume of a cylinder with radius first and height second. hint: the volume of a cylinder is simply the area of the circle at the base times the height. if the value of description is "sphere" it returns the volume of the sphere with radius first. otherwise it returns -1.0;
Answers: 1
question
Computers and Technology, 23.06.2019 04:00
Another name for addicting games.com
Answers: 1
question
Computers and Technology, 23.06.2019 04:31
Type the correct answer in the box. spell all words correctly. the managing director of a company sends a christmas greeting to all his employees through the company email. which type of network does he use? he uses an
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
What are loans to a company or government for a set amount of time
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
English, 15.12.2020 08:20
question
English, 15.12.2020 08:20
question
Mathematics, 15.12.2020 08:20
Questions on the website: 13722360