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
FOR ALL PLATO USERS:
aleksley [76]

You have to ask you teacher to show you which ones you got wrong and the answers to them.

6 0
4 years ago
Read 2 more answers
Which of the following is an attack that adds SQL statements to input data for the purpose of sending commands to a database man
liq [111]

Answer: SQL Injection

Explanation:

The SQL injection is one of the type of attack which is used in the database management system for sending the commands by adding the structured query (SQL) language statement in the form of input data.

  • The SQL injection is the technique of code injection in which the SQL statement for the purpose of sending commands.  
  • It is widely used in the data driven applications.
  • The various types of web applications and web pages are used the SQL injection and uses in the form of input in the SQL query and then it is executed in the database.

Therefore, The SQL injection is the correct option.

5 0
3 years ago
which of the following are used on cable trays to protect the cable insulation from direct sunlight? a. barrier strips b. solid
laila [671]
The answer is barrier strips
7 0
3 years ago
Given two integers as user inputs that represent the number of drinks to buy and the number of bottles to restock, create a Vend
Zanzabum

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);

 }

}

7 0
3 years ago
Draw the gates required to build a half adder.
Svetach [21]

Answer:

The gates required to build a half adder are :

  1. AND Gate for Carry.
  2. XOR Gate for Sum

Explanation:

AND Gate is required for the carry and the XOR gate is required for the sum.

The figures for the gates and the truth tables for the half adder are attached so please refer them for further explanation.

The sum is 1 when one of the input is High or 1 if both the inputs are same then the sum is 0.So this behavior is implemented by X-OR gate.

The carry is High only when both of the inputs are 1.This is implemented by AND-Gate.

6 0
3 years ago
Other questions:
  • What Coding program does UNITY use?
    6·1 answer
  • Part 1 Create a program that asks the user for a temperature in Fahrenheit, and then prints the temperature in Celsius. Search t
    12·1 answer
  • What does the regular expression [a-z0-9\-] mean?
    8·1 answer
  • ____________ is a series of numbers that identifies a particular computer. They may or may not be a reliable way to link you to
    14·1 answer
  • Is something wrong with Brainly?
    5·2 answers
  • Tables should be used when (a) the reader need not refer to specific numerical values. (b) the reader need not make precise comp
    14·1 answer
  • Fiber optic cables transfer data at the speed of light, so they have the __________ latency. This results in the ________ connec
    13·1 answer
  • Define each of the following data mining functionalities: characterization, discrimination, association and correlation analysis
    9·1 answer
  • Your data warehousing project group is debating whether to create a prototype of a data warehouse before its implementation. The
    12·1 answer
  • 2.9.8 stop light codehs
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!