1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Reptile [31]
3 years ago
10

Given two integers as user inputs that represent the number of drinks to buy and the number of bottles to restock, create a Vend

ingMachine 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

Need this answer in java! !!!!!!!!!!!!
Computers and Technology
1 answer:
Zanzabum3 years ago
7 0

Answer:

import java.util.Scanner;

class Main {

 public static void main (String args[])

 {

   Scanner input = new Scanner(System.in);

   VendingMachine machine = new VendingMachine(20);

   System.out.print("Enter nr to purchase: ");

   int nrPurchased = input.nextInt();

   System.out.print("Enter nr to re-stock: ");

   int nrRestock = input.nextInt();

   machine.Transaction(nrPurchased, nrRestock);

   input.close();

 }

}

class VendingMachine {

 private int inventory;

 public VendingMachine(int initialInventory) {

   inventory = initialInventory;

 }

 public void Transaction(int nrToBuy, int nrToRestock) {

   inventory += nrToRestock - nrToBuy;

   System.out.printf("Inventory: %d bottles.\n", inventory);

 }

}

You might be interested in
What can relaxation help to reduce?
morpeh [17]
It can reduce stress
3 0
3 years ago
What is cloud computing?
Luba_88 [7]
According to google, cloud computing. <span>the practice of using a network of remote servers hosted on the Internet to store, manage, and process data, rather than a local server or a personal computer.</span>
4 0
3 years ago
Tiffany is writing a program to help manage a bake sale. She writes the following code which prompts the user to enter the total
PtichkaEL [24]

Answer:

Explanation:

the answer is also in the question. The loop is used to control the number of  program execution. So in order not to run forever, the loop should be included inside the loop brackets. Then you can restructure the code as done below.

var numItems = promptNum("How many items?");

var total = 0;

var itemPrice=0;

while (numItems > 0){

itemPrice = promptNum("Enter next item price");

total = total + itemPrice;

numItems = numItems - 1;

}

console.log("The total is" + total);

The value to be displayed will be the total of the item prices inputted.

8 0
4 years ago
what is the greatest number of bits you could borrow from the host portion of a class b subnet mask and still have at least 130
Lina20 [59]

The greatest number of bits you could borrow from the host portion of a class b subnet mask and still have at least 130 host per subnet is 24.

<h3>What is a host bit?</h3>

Host bits are known to be the parts of an IP address that can state out a particular host in any subnet.

Note that whenever we take or borrow an host-bit, we can also double the number of subnets that we are said to create and as such, when we borrowing 2 host bits we can have 4 subnets.

Learn more about Bits from

brainly.com/question/19667078

6 0
2 years ago
What is the missing line?
gregori [183]

Correct question:

What is the missing line?

>>> myDeque = deque('math')

>>> myDeque

deque(['m', 'a', 't'])

Answer:

myDeque.pop()

Explanation:

The double ended queue, deque found in the python collection module is very similar to a python list and can perform operations such as delete items, append and so on.

In the program written above, the missing line is the myDeque.pop() as the pop() method is used to delete items in the created list from the right end of the list. Hence, the 'h' at the right end is deleted and we have the output deque(['m', 'a', 't'])

myDeque.popleft () deletes items from the right.

4 0
3 years ago
Other questions:
  • Internet-filtering software that electronically blocks out websites in specific rating categories is called _____________ by tho
    9·1 answer
  • Which symbol is used to identify edge-triggered flip-flops? a triangle on the clock input. the letter e on the enable input. a b
    14·1 answer
  • 1)
    9·1 answer
  • Universal Container sales reps can modify fields on an opportunity until it is closed. Only the sales operations team can modify
    13·1 answer
  • Pls help with this (20 points again)
    8·1 answer
  • An algorithm is Group of answer choices The part of the computer that does the processing A complete computer program The inputs
    6·1 answer
  • Which of the following is not part of the processes involved in data valida
    11·1 answer
  • Which of the following is/are used in multimedia?
    14·1 answer
  • Advantages and disadvantages of a watch tower​
    15·1 answer
  • 8. Give regular expressions with alphabet {a, b} for
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!