Please make the program as basic as possible, meaning don\'t use high level Java
ID: 3557789 • Letter: P
Question
Please make the program as basic as possible, meaning don't use high level Java syntax.
Vending Machine program needed in JAVA.
Write a program that simulates the functionality of a vending machine having the following characteristics:
Explanation / Answer
import java.util.*; public class VendingMachineAssignement { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); double item1 = 1.25; double item2 = .75; double item3 = .90; double item4 = .75; double item5 = 1.50; double item6 = .75; System.out.print("Enter an item number: "); int item = keyboard.nextInt(); System.out.print("Enter the amount paid: "); double paid = keyboard.nextDouble(); if (item == 2 || item == 4 || item == 6) { if (paid >= item2) { System.out.println("Thank you for buying item " + item + ", your change is $" + (paid-item2) + ". Please come again!"); } if (paid = item1) { System.out.println("Thank you for buying item " + item + ", your change is $" + (paid-item1) + ". Please come again!"); } if (paid = item3) { System.out.println("Thank you for buying item " + item + ", your change is $" + (paid-item3) + ". Please come again!"); } if (paid = item5) { System.out.println("Thank you for buying item " + item + ", your change is $" + (paid-item5) + ". Please come again!"); } if (paidRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.