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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 09:00, breella0
Howard is designing a chair swing ride. the swing ropes are 5 meters long, and in full swing they tilt in an angle of 29° outside chairs to be 2.75 m above the ground in full swing.
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, shadowsnake
Write a function called checkfactor that takes two arrays of positive numbers, firstnumberrow and secondnumberrow. checkfactor checks if the first entry in firstnumberrow is divisible by the first entry in secondnumberrow, and performs the same operation on the next array elements until all entries have been checked. all the numbers are positive and the number of entries in the arrays are the same. the function should return the identified divisible numbers in two row arrays named firstdivisible and seconddivisible. restrictions: branches or loops should not be used. the code must use the internal mod and logical functions. hint: the mod function should be used to determine if two numbers are divisible. ex: for num1 and num2 if mod(num1,num2) is 0, then the two numbers are divisible. this is matlab
Answers: 2
image
Computers and Technology, 24.06.2019 01:00, bellamyciana
What are two ways to access the options for scaling and page orientation? click the home tab, then click alignment, or click the file tab. click the file tab, then click print, or click the page layout tab. click the page layout tab, or click the review tab. click the review tab, or click the home tab?
Answers: 2
image
Computers and Technology, 24.06.2019 02:10, ttangelique
Which sentences describe the things you need to ensure while creating a sketch and a drawing? while an artistic or creative drawing is a creative expression, a technical drawing is an informative expression. you need to create accurate and neat drawings to convey accurate information. a technical drawing clearly conveys its meaning or information, and does not leave room for interpretation maintain a good speed while creating drawings
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 in other subjects:

Konu
Mathematics, 14.01.2021 07:50
Konu
Mathematics, 14.01.2021 07:50
Konu
Mathematics, 14.01.2021 07:50