This is the output below. I am given the 3 menu items, prices, and 3 Product numbers.
I have to create the source code. I am using elcipse ( My code at bottom)
OUTPUT
__________________________________________________ __________________________________________________ ________________________________
Enter ItemNumber of Product (OR ZERO to end) order.
1
Cheeseburger $2.49
Enter ItemNumber of Product (OR ZERO to end) order.
2
Pepsi
Enter ItemNumber of Product (OR ZERO to end) order.
3
Chips
Enter ItemNumber of Product (OR ZERO to end) order.
4
Sorry, we do not carry that item.
4 Enter ItemNumber of Product (OR ZERO to end) order.
0
Billy Goat Fast-Foods
Description Price
------------ -----
Cheeseburger $2.49
Pepsi $1.00
Chips $0.59
The total cost of this order is $ 4.08
Thank you from Bily Goat Fast-Foods.
__________________________________________________ __________________________________________________
My start on this problem
__________________________________________________ __________________________________________________ ____________________________________<YOUR CODE HERE> import.java.util.Scanner; public class BillyGoatArrays { public static void main(String[] args) { Scanner input = new Scanner (System.in); int itemNumber [] = {1,2, 3}; String menu[] = {"Cheeseburger", "Pepsi", "Chips"}; double price[] = {2.49, 1.00, 0.59}; int loopIndex = 0; for (loopIndex = 0; loopIndex < 3; loopIndex++) { System.out.println("Enter itemNumber of Product or enter ZERO to end order"); System.out.println("Menu is = " + menu[loopIndex]); System.out.println(menu[loopIndex] +" Price is = " + price[loopIndex]); } } }
I think I can figure out the print prompts . I am stuck on the array for the item number and the message for item 4. I do not understand why item number 4 shows up in output twice in a row but shows the Sorry message only once. To get the program to display all of the products sequentially and then total them has me stuck. I am wondering if I need an if statement for the number 4. Instructor says he wants this program to allow up to 100 items to be ordered. I don't know how to make the third array of item numbers with an index of 100 . Would I do something like itemnumber[100] and then go itemnumber[1] = cheeseburger, itemnumber [2] = Pepsi... and so on and then do the Sorry message for item number 4, or would I do some type of catch statement? I don't want the answers given to me.. Just a little guidance. My instructor is a a very old programmer and he DOES not Teach. He just throws this stuff at us with the chapter and expects it done when this is supposed to be our first INTRO to Programmming class. Basically everyone eventually copies the program of the one guy in the class that has a programming background.. But I don't learn anythng this way.. A littel advice appreciated. I also still have to creat a scanner object to allow console input.. That I know.. Setting the item numbet array to not use zero so it can be used as a way to end loop and total order is beyond me, too.