Question

In: Other

Coding Java Vending machine Lab


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






import java.util.Scanner;

public class LabProgram {
   public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);
      
      /* Type your code here. */ 
      
   }
}


Solutions

Expert Solution

import java.util.Scanner;


public class LabProgram {

        

        public static void main(String[] args) {

                

                Scanner reader = new Scanner(System.in);

                

                int initial = 20;

                int noOfDrinks = reader.nextInt();

                int restocs = reader.nextInt();

                

                int remaining = initial - noOfDrinks + restocs;

                

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

                

                reader.close();

                

        }

        

}



Related Solutions

In Java): A vending machine serves chips, fruit, nuts, juice, water, and coffee. The machine owner...
In Java): A vending machine serves chips, fruit, nuts, juice, water, and coffee. The machine owner wants a daily report indicating what items sold that day. Given boolean values (true or false) indicating whether or not at least one of each item was sold (in the order chips, fruit, nuts, juice, water, and coffee), output a list for the owner. If all three snacks were sold, output "All-snacks" instead of individual snacks. Likewise, output "All-drinks" if appropriate. For coding simplicity,...
Write a java console application,. It simulates the vending machine and ask two questions. When you...
Write a java console application,. It simulates the vending machine and ask two questions. When you run your code, it will do following: Computer output: What item you want? User input: Soda If user input is Soda Computer output: How many cans do you want? User input:            3 Computer output: Please pay $3.00. END The vending machine has 3 items for sale: Soda the price is $1.50/can. Computer should ask “How many cans do you want?” Chips, the price is $1.20/bag....
Sam is considering purchase of a vending machine to sell sodas. The cost of the vending...
Sam is considering purchase of a vending machine to sell sodas. The cost of the vending machine is $3,400. Sam estimates that the vending machine will last for five years and will provide net income of $800 each year for its lifetime. a. If Sam pays $3,400 for the vending machine today, what is its net present value at 7%? Should Sam purchase the vending machine? b. If Sam pays $3,400 for the vending machine today, what is its net...
Simon Teguh is considering investing in a vending machine operation involving 20 vending machines located in...
Simon Teguh is considering investing in a vending machine operation involving 20 vending machines located in various plants around the city. The machine manufacturer reports that similar vending machine routes have produced a sales volume ranging from 600 to 800 units per machine per month. The following information is made available to Teguh in evaluating the possible profitability of the operation. An investment of $45,000 will be required, $9,000 for merchandise and $36,000 for the 20 machines. The machines have...
The objective of this lab is to practice your Verilog coding and the design of a...
The objective of this lab is to practice your Verilog coding and the design of a Finite State Machine. Lab Goal: For this lab, you will code a Verilog module to implement the FSM described in this document. This lab will also require that you use the Seven - Segment Display on the DE0 - CV FPGA board. Design Specifications for the FSM Implem ent the following simple state machine on the DE0 - CV FPGA board. This FSM will...
A soft drink vending machine dispenses cans of drinks at the JKUAT cafeteria. The machine waits...
A soft drink vending machine dispenses cans of drinks at the JKUAT cafeteria. The machine waits for students and/or staff to insert coins. All soft drinks cost KShs. 50 and the machine can only accept Ten, Twenty and Forty shilling coins. A customer must insert a total of fifty shillings for the machine to dispense drinks. (i.)      Give the formal definition of the above machine, as a Finite Automaton. (ii.)     Is the machine deterministic or non-deterministic? Justify your answer (iii.)    Draw a state...
1-You want to dispense an item from the vending machine. An item in the machine can...
1-You want to dispense an item from the vending machine. An item in the machine can cost between 25 cents and a dollar, in 5 cent increments (25,30,35,,40,45......,90,95,100) and the machine accepts only a single dollar bill to pay for the item. Write a java class called ChangeMaker that will determine the change to be dispensed from a vending machine. Use the following UML diagram. ChangeMaker        Attributes    private double money    private int numberOfQuarters    private int...
Create a Class with Data Fields and Methods in Java. Provide a Java coding solution for...
Create a Class with Data Fields and Methods in Java. Provide a Java coding solution for the following: 1. Name the class SalonServices 2. Add private data fields: a. salonServiceDescription – This field is a String type b. price - This field is a double type 3. Create two methods that will set the field values. a. The first method setSalonServiceDescription() accepts a String parameter defined as service and assigns it to the salonServiceDescription. The method is not static b....
A manufacturer of coffee vending machines has designed a new, less expensive machine. The current machine...
A manufacturer of coffee vending machines has designed a new, less expensive machine. The current machine is known to dispense an average of 5 fl. oz., with a standard deviation of .2 fl. oz., into cups. When the new machine is tested using 15 cups, the mean and the standard deviation of the fills are found to be 5 fl. oz. and .213 fl. oz. Test H0: σ = .2 versus Ha: σ ≠ .2 at levels of significance .05...
You are running a grocery store thinking about installing the Sushi 1000 vending machine. The machine...
You are running a grocery store thinking about installing the Sushi 1000 vending machine. The machine costs $100,000 today (year 0) and will last six years (years 1 through 6). Assume annual sales in years 1 through 6 will be $75,000, costs will be $50,000, and depreciation will be $20,000 (straight-line). Assume a discount rate of 10%. Calculate the cash flows and NPV of this project first assuming a corporate tax rate of 0% and then assuming a corporate tax...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT