Hello, my name is Ryan I have been set an assignment for my procedural programming teacher to create a very simplistic and basic vending machine. I have elected to make my version in Java and have currently hit a wall in my progress. This is the code I have constructed at the moment.
package cool;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int Black_Tea = 1;
int White_Tea = 2;
int Black_Coffee = 3;
int White_Coffee = 4;
int Cappaccino = 5;
int Hot_Chocolate = 6;
System.out.println("Welcome User!");
System.out.println("Please Select a number relative to your choice from the menu below:");
System.out.println("1 - Black Tea");
System.out.println("2 - White Tea");
System.out.println("3 - Black Coffee");
System.out.println("4 - White Coffee");
System.out.println("5 - Cappuccino");
System.out.println("6 - Hot Chocolate");
Scanner scanner = new Scanner(System.in);
As you can see I haven't really done much but I have made a start. As you can see I have tried to assign variables for each of the items I wish my vending machine to dispense. With them variables I am trying to make it so the user can simply input a number that is relative to the item the wish to purchase. For instance, If I wanted some White Coffee I would simply input the number 4.
This is were my troubles develop. How can I make it so the scanner understands what information has been selected and save that as a variable to use throughout the process. Just like when 1 is selected the scanner then is equal to 1 and in extension 1 is equal to the variable "Black Tea". After this I am planning to create an if statement for each of the items.
Any help and advice is welcome and would be much appreciated
I am rather experience and don't understand everything about JAVA at the moment so there might be something very simple I am missing that will allow me to continue in the creation of this vending machine.
Thanks.