I am working on a program that mimics a vending machine, it needs to pull data from a .txt file and use that information in the program. I want it to ask the user to input their amount of money and give them change as well. I want to store the prices in 2d arrays as well as the item names then have the user pick an item to buy. I am not sure how to go about this!! I really need some help, this is what I have so far.
Code:
import java.util.*;
import java.io.File;
import java.io.FileNotFoundException;
public class Vending
{
public static void main(String[] args) throws FileNotFoundException
{
System.out.print("Enter your food selection file: "); // User inputs file
Scanner input = new Scanner(System.in); // Keyboard input from user
Scanner fs = new Scanner(new File(input.nextLine())); // Scans in the file that was inputed
}
double price = 0;
while(fs.hasNextLine()){
fs.next();
price = fs.nextDouble();
System.out.print(price);
}
}
Item list file (Food.txt):
1 Honey roasted peanuts 1.50 Cheetos 1.50 Bugles 2 Synder’s Pretzels 1 Snickers 1 Twix 1.25 M n Ms .75 Life savers 1 Twizzlers 1 Nutter Butters 1 Butter Fingers 1.50 King Size Kit Kats 1.25 Carrot sticks .50 Juicy Fruit .50 Spearmint Gum .50 Five gum 3.50 Pepperoni 1.75 Cheez-Its .25 Slim Jim 1.50 Lays Barbeque Chips