subject
Computers and Technology, 19.01.2021 19:30 arely30

LAB: Vending machine 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 VendingMachine 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
LAB ACTIVITY 7.13.1: LAB: Vending machine
Current file: LabProgram. java Load default template...
1 import java. util. Scanner;
2
3 public class LabProgram {
4 public static void main(String[] args) {
5 Scanner scnr = new Scanner(System. in);
6
7 /* Type your code here.*/ 8
8 VendingMachine v1 = new Vending Machine();
9 v1.purchase() = scnr. nextint();
10 v1.purchase() = scnr. nextint();
11 v1.restock(20);
12 v1.report();
13 }
14 }
15
LAB ACTIVITY 7.13.1: LAB: Vending machine
File is marked as read only Current file: Vending Machine. java
1 // simulates a simple vending machine with operations to purchase drinks and check inventory.
2 public class VendingMachine {
3
4 // number of bottle in stock
5 private int bottles;
6
7 // initial inventory is 20
8 public Vending Machine() {
9 bottles = 20;
10 }
11
12 public void purchase(int amount) {
13 bottles = bottles - amount;
14 }
15
16 public int getInventory (){
17 return bottles;
18 }
19
20 public void restock(int amount) {
21 bottles = bottles + amount;
22 }
23
24 public void report({
25 System. out. println("Inventory: " + bottles + bottles + " bottles");
26 }
27
28 }
29

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:00
Robots with telescoping arms are sometimes used to perform tasks (e.g., welding or placing screws) where access may be difficult for other robotic types. during a test run, a robot arm is programmed to extend according to the relationship r = 3 + 0.5cos(4θ) and the arm rotates according to the relationship θ=−π4t2+πt , where r is in feet, θ is in radians, and t is in seconds. use a computer program to plot the path of tip a in x and y coordinates for 0 ≤ t ≤ 4s.
Answers: 2
question
Computers and Technology, 22.06.2019 23:30
Jaina and tomas are being considered as new tenants in an apartment. the landlord looks at their creditworthiness because he wants to be sure his new tenant pays the rent on time and in full. the table below summarizes the information that was on their applications. application information questions jaina tomas how many years have you had your job? 5 2 what is your monthly salary? $1,850 $2,500 how many credit cards do you have? 4 1 how much debt do you have? $13,000 $7,000 how many times were you late with payments on credit cards in the past year? 5 1 who will the landlord decide to be more creditworthy and why? tomas because the ratio of his debt to income is less. jaina because she has had her job longer, which makes her look more stable. jaina because she has more credit cards available to her. tomas because he makes more money per month.
Answers: 2
question
Computers and Technology, 23.06.2019 22:00
Technician a says engine assemblies can be mounted longitudinally in a chassis. technician b says engine assemblies can be mounted transversely in a chassis. who is correct?
Answers: 2
question
Computers and Technology, 24.06.2019 12:00
How can we take picture in this app
Answers: 1
You know the right answer?
LAB: Vending machine Given two integers as user inputs that represent the number of drinks to buy a...
Questions
question
Mathematics, 27.08.2019 02:40
question
Mathematics, 27.08.2019 02:40
Questions on the website: 13722361