Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program using Java Programming Language Object-oriented Programming Assi

ID: 3720135 • Letter: W

Question

Write a program using Java Programming Language

Object-oriented Programming Assignment #7 Deadline: Tuesday, May 1 1. Program to be implemented You need to simulate a Vending Machine which Accepts coins of 1,5,10,25 Cents i.e. penny, nickel, dime, and quarter Allow user to select products Coke(25), Pepsi(35), Soda(45) Allow user to take refund by canceling the request. Return selected product and remaining change if any Allow reset operation for vending machine supplier 2. 4 2. Guidelines (1) Implement each class for each shape. At least, implement the following classes VendingMachine to represent a Vending Machine Item to represent ltems served by Vending Machine Coin that to represent Coins supported by Vending Machine (2) Implement VendingMachineSimulator to get a user's input and generate the result. (3) Define methods as many as possible for each class (4) Declare data as private (5) To make this simulator, you can refer to "Design a Vending Machine in Java - Interview Question," http://javarevisited.blogspot.kr/2016/06/design-vending-machine-in-java.html. However, you should not use the knowledge that you have not learned (i.e., Interface, Factory, Exception) 3. Evaluation Criteria (1) Indentation Rules » If your code violates the indentation rules, your points will be decreased a lot. (2) Program Description Explanation of the Class Explanation of the Fields and the Methods · e Explanation of the Program Structure (3) Program Structure Does the source code include the classes for VendingMachinem, Item, and Coin? » Does the source code include the simulator of a vending machinet? (4) Execution of the program 4. Submission of the followings: (1) Source Code (2) Program Description (3) Screenshot of the Results

Explanation / Answer

only first four parts are answered as per chegg policy:

//enum's are used for grouping similar data

public class vendingmachine{

private long totalSales;

private Item currentItem;

private long currentBalance;

public long selectItemAndGetPrice(Item item){

}

}

public void insertCoin(Coin coin)

{

;

}

public class item{

public enum Item{

COKE("Coke", 25), PEPSI("Pepsi", 35), SODA("Soda", 45);SODA("Soda", 45);

private String name;

private int price;

private Item(String name, int price)

{ this.name = name; this.price = price; }

}

public String getName()

{ return name; }

public long getPrice(){

return price;}

}

public class coin(){

enum Coin

{ PENNY(1), NICKLE(5), DIME(10), QUARTER(25);

private int denomination;

private Coin(int denomination){

this.denomination = denomination; }

public int getDenomination(){

return denomination; }

}


public class VendingMachineSimulator{

public static void main(String args[])

  {

int userChoice = 0;

public static void menu()

  {

    System.out.println("Available Commands");

    System.out.println();

    System.out.println("0. Show commands");

    System.out.println("1. Display inventory");

    System.out.println("2. Display currency");

    System.out.println("3. Purchase item");

    System.out.println("4. Exit");

    System.out.println();

  }

public static void purchaseItem()

  {

    System.out.print("Item #: ");

    int item = input.nextInt();

    System.out.print("How many different currency items?: ");

    int x = input.nextInt();

    System.out.println("Available currency denominations");

     

    for (int i = 0; i < currency.length; i++)

    {

      System.out.println("Currency #: " + i + ": " + currency[i].toStringShort());

    }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote