Question

Write a program for a vending machine. The vending machine when powered on will initially have zero drinks stored in its hoppers. There are three kinds of drinks in the machine.
The machine has two modes of operation: Admin mode and user mode.
When powered it will display a log in for the admin, the log in screen will ask for a password which is admin123. Should that entry be wrong, the screen will prompt for the password again. After three tries, the machine will no longer prompt for the password but will terminate the program and exit.
If the password is correct, the machine will display the current inventory with a menu to choose drink types for replenishing. You should have a maximum of 5 drinks per category (remember you have only three types). The replenishing level doesn’t have to max out but an error will occur if the admin tries to enter a number higher than present capacity. The admin should also be able to set the price for the drinks. They should all have the same price regardless of category. The default price is $1.00.
Once the machine is replenished the admin can choose to exit admin mode and only then would user mode start. User mode should display a choice of beverages and an option to purchase. An admin option should be present so that the user mode can be interrupted.
Only the admin can terminate the program or when there are no more drinks in the machine.
At any given time, the admin can log in and check how much money is collected and what the status of the inventory is.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.Scanner;


public class VendingMachine {

public static String adminPassword = "admin123";
public static String[] type = {"Coke", "Sprite", "Dr. Pepper"};
public static int maxSodas = 5;

public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int count = 0;
int[] inv = {0, 0, 0};
double price = 1.0;
double collected = 0.0;
String pass;
while(count != 3)
{
System.out.print("Welcome to the vending machine admin mode, please enter the password: ");
pass = input.next();
if(pass.compareTo(adminPassword) == 0)
{
break;
}
else
{
System.out.println("Incorrect password, try again");
count++;
}
}
if(count == 3)
{
System.out.println("Too many attempts, closing program");
return;
}

while(true)
{...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

World Puzzle Problem & Arrays in Java
Homework Solution
$60.00
Java
Programming
Codes
Algorithms
Arrays
Word Puzzles
Input
Output
Running Time
Integers
Loops
Maximum Count
Divide And Conquer Method
Statements
Variables
Recursive Calls
Java Programming: Printing The Pattern
Homework Solution
$10.00
Java
Programming
Computer Science
Loops
Printing
Patterns
Rows
Loops
Statements
Variables
Integers
Strings
Input
Output
Rock, Paper, Scissors Program
Homework Solution
$60.00
Programming
Java
Computer Science
Rock Paper Scissors
Game
MySQL
Tables
Queries
Results
Rounds
Probability
Loops
Conditions
Winning
Losing
User vs Computer
Databases
Java Programming: Arrays Of Marks & Circles
Homework Solution
$50.00
Java
Programming
Codes
Computer Science
Algorithms
Arrays
Marks
Circles
Geometry
Mathematics
Radius
Random Numbers
Boundaries
Statements
Loops
Variables
Points
Coordinates
Perimeters
Area
Get help from a qualified tutor
Live Chats