Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Please help! Need help with class project!

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    5
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please help! Need help with class project!

    Hi i'm new to this site.

    I've been working on this project for my Programming Fundamentals class and I keep getting stuck, I can't seem to get it working properly.

    If anyone can help me out I would really really appreciate it as I might not pass the course if I don't get this done. The program we use to code is Eclipse.


    I've attached a zip file with my java file and a doc file with the instructions for the project. Thanks again to anyone that can help.
    Attached Files Attached Files


  2. #2
    Junior Member
    Join Date
    Apr 2012
    Posts
    5
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please help! Need help with class project!

    Also, I am only doing the MILD version of the project, not the HOT version on page 6-9 of the doc file.

  3. #3
    Member
    Join Date
    Jan 2012
    Location
    Hellas
    Posts
    284
    Thanks
    11
    Thanked 59 Times in 57 Posts

    Default Re: Please help! Need help with class project!

    Quote Originally Posted by eldeeb_hasan View Post
    Also, I am only doing the MILD version of the project, not the HOT version on page 6-9 of the doc file.
    Hello eldeeb_hasan!
    Can you post your code here and explain where are you getting stuck? It' not very convienient downloading your attachments.

  4. #4
    Junior Member
    Join Date
    Apr 2012
    Posts
    5
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please help! Need help with class project!

    Sure. I'm supposed to make a Resturaunt Order program which first asks how many people are in the group, then asks each one what they would like for an Appetizer, Entree, Dessert, and Beverages. The selections for each of those sub-menu's have to be put in arrays then the user will be prompted to enter 1,2,3,4,etc. for whichever choice.

    So, It would have to be like:

    Taking diner #1's order:
    then the user selects from the sub menus using the appropriate numbers, and then that code loops for the 2nd, 3rd, 4th, etc. diners.

    This is my code so far, it might be a bit messy:

    /**
     * Program Name:ResturauntOrder.java
     * Purpose: 
     * Date:Mar 29, 2012
     */
    import java.text.DecimalFormat;
    import java.util.Scanner;
    public class ResturauntOrder
    {
     
    	public static void main(String[] args)
    	{
    		// Create Scanner
     
    		Scanner input = new Scanner(System.in);
     
    		// 1. Display a title
     
    		System.out.println("   Welcome to my Café!   \n******************************");
     
    		// 2.	Ask the user to enter the number of people in the group
     
    		//final int ARRAY_SIZE;
     
    		System.out.print("How many people there are in your group: ");
    		//ARRAY_SIZE = input.nextInt();
    		int peopleInGroup = input.nextInt();
     
    		System.out.println("\nEach person will need to order an item from each menu category including \nappetizer, entree, dessert, and beverage.");
    		System.out.println("\nI will ask each diner for all their menu selections.");
     
    		// 3.	Create and populate eight arrays, two for each sub-menu. 
     
    		String[] appetizer = {"","No Selection","Deep Fried Calamari","Soup du Jour","Garden Salad","Garlic Bread"};
     
    		double[] appetizerPrice = {0.00,0.00,7.50,4.99,3.99,4.50};
     
     
    		String[] entree = {"","No Selection","Rib-Steak","Fettuccini Alfredo","Pan-Fried Sole","Mediterranean Platter","Vegetarian Lasagna"};
     
    		double[] entreePrice = {0.00,0.00,15.95,11.25,17.95,13.50,9.00};
     
     
    		String[] dessert = {"","No Selection","Ice Cream Sundae","Cheesecake","Chocolate Truffle Cake","Raspberry Mousse"};
     
    		double[] dessertPrice = {0.00,0.00,2.95,5.00,6.00,4.50};
     
     
    		String[] beverage = {"","No Selection","Water","Juice","Pop","Milk","Coffee","Tea"};
     
    		double[] beveragePrice = {0.00,0.00,0.00,2.00,2.00,2.00,1.75,1.75};
     
    		// 4.	Declare and initialize a variable to hold the total bill for all the food ordered by the entire group
     
    		double totalBill = 0;
     
    		// 5.	Next generate the food order by asking the user to select one item from each sub-menu for each diner
     
    			// i.	Display the diner number that is currently ordering food
     
     
    			int i = 1;
    			int [] appetizerChoice = new int [i];
     
    			int [] entreeChoice = new int [i];
     
     
    			int [] dessertChoice;
     
     
    			int [] beverageChoice;
     
     
    			String [] appetizerString = {""};
    			String [] entreeString = {""};
     
     
     
    			[highlight]while(i < peopleInGroup | i == peopleInGroup)
    			{
     
    				while (appetizerChoice[i] < 1 | appetizerChoice[i] > 5)
    				{[/highlight]
     
     
    					System.out.println("\nNow taking diner #" + i + "'s order...\n-------------------------------");
     
    					System.out.println("\nPlease select one item from the Appetizer menu.");
    					System.out.println("1. ** No Selection ** $0.00");
    					System.out.println("2. Deep Fried Calamari $7.50");
    					System.out.println("3. Soup du Jour $4.99");
    					System.out.println("4. Garden Salad $3.99");
    					System.out.println("5. Garlic Bread $4.50"); 
     
    					System.out.print("\nWhat is your selection?");
     
    					appetizerChoice[i] = input.nextInt();
     
    				}
     
     
    				[highlight]switch(appetizerChoice[i])
    			  {
    				case 1: appetizerString[i] = appetizer[1];
    				break;
     
    				case 2:appetizerString[i] = appetizer[2];
    		  	totalBill = totalBill + appetizerPrice[2];
    				break;
     
    				case 3: appetizerString[i] = appetizer[3];
    		  	totalBill = totalBill + appetizerPrice[3];
    				break;				
     
    				case 4:appetizerString[i] = appetizer[4];
    		  	totalBill = totalBill + appetizerPrice[4];
    				break;
     
    				case 5:appetizerString[i] = appetizer[5];
    		  	totalBill = totalBill + appetizerPrice[5];
    		  	break;
     
    				default: System.out.println("You must make a valid choice...");
    				}[/highlight]
     
    			  while (entreeChoice[i] < 1 | entreeChoice[i] > 6)
    			  {
    			  	System.out.println("\nPlease select one item from the Entree menu.\n");
    			  	System.out.println("1. ** No Selection ** $0.00");
    			  	System.out.println("2. Rib-Steak $15.95");
    			  	System.out.println("3. Fettuccini Alfredo $11.25");
    			  	System.out.println("4. Pan-Fried Sole $17.95");
    			  	System.out.println("5. Mediterranean Platter $13.50");
    			  	System.out.println("6. Vegetarian Lasagna $9.00");
     
    			  	System.out.print("\nWhat is your selection?");
     
     
    			  	entreeChoice[i] = input.nextInt();
    			  }
     
    			  	switch(entreeChoice[i])
    			  	{
    			  	case 1: entreeString[i] = entree[1];
    			  	break;
     
    			  	case 2: entreeString[i] = entree[2];
    			  	totalBill = totalBill + entreePrice[2];
    			  	break;
     
    			  	case 3: entreeString[i] = entree[3];
    			  	totalBill = totalBill + entreePrice[3];
    			  	break;				
     
    			  	case 4: entreeString[i] = entree[4];
    			  	totalBill = totalBill + entreePrice[4];
    			  	break;
     
    			  	case 5: entreeString[i] = entree[5];
    			  	totalBill = totalBill + entreePrice[5];
    			  	break;
     
    			  	case 6: entreeString[i] = entree[6];
    			  	totalBill = totalBill + entreePrice[6];
    			  	break;
     
    			  	default: System.out.println("You must make a valid choice...");
    			  	}
    			  i++;
    			  }
     
     
     
     
     
      System.out.println("\nThank You! Your order consists of:\n\t" + appetizerString +
    			"\n\t" + entreeString);
    	System.out.println("----------------------------------------------------"+
    			"\nOrder completed. Your total bill comes to $"+ totalBill +
    			"\n----------------------------------------------------");	
     
     
     
     
    	}//end main
     
     
    }//end class
    Last edited by eldeeb_hasan; April 9th, 2012 at 07:36 PM.

  5. #5
    Junior Member
    Join Date
    Apr 2012
    Posts
    5
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please help! Need help with class project!

    Also, here are the instructions for the project:

    Write a Java program called RestaurantOrder.java that will do all of the following:
    1. Display a title

    2. Ask the user to enter the number of people in the group

    3. Create and populate eight arrays, two for each sub-menu.

    There will be four sub-menus: appetizers, entrées, desserts and beverages. For each sub menu you will create a String array of the item descriptions and an array of doubles to hold the prices for each item. For example, if the 4th item in the descriptions array is “Garden Salad”, then the price for this should be the 4th item in the corresponding prices array.

    The sub-menu descriptions and prices should be EXACTLY as follows: (I couldn't get these tables to paste properly, I hope you can make sense of them)

    Appetizer Sub-Menu Entrée Sub-Menu
    # Description Price # Description Price
    1
    2
    3
    4
    5 No selection
    Deep Fried Calamari
    Soup du Jour
    Garden Salad
    Garlic Bread $0.00
    $7.50
    $4.99
    $3.99
    $4.50 1
    2
    3
    4
    5
    6 No selection
    Rib-Steak
    Fettuccini Alfredo
    Pan-Fried Sole
    Mediterranean Platter
    Vegetarian Lasagna $0.00
    $15.95
    $11.25
    $17.95
    $13.50
    $9.00

    Dessert Sub-Menu Beverage Sub-Menu
    # Description Price # Description Price
    1
    2
    3
    4
    5 No selection
    Ice Cream Sundae
    Cheesecake
    Chocolate Truffle Cake
    Raspberry Mousse $0.00
    $2.95
    $5.00
    $6.00
    $4.50 1
    2
    3
    4
    5
    6
    7 No selection
    Water
    Juice
    Pop
    Milk
    Coffee
    Tea $0.00
    $0.00
    $2.00
    $2.00
    $2.00
    $1.75
    $1.75


    4. Declare and initialize a variable to hold the total bill for all the food ordered by the entire group. This will be used like a running total as food items are selected for each diner.

    5. Next generate the food order by asking the user to select one item from each sub-menu for each diner.
    a. Code a loop that will iterate once for each diner in the group. Within this loop you will:
    i. Display the diner number that is currently ordering food.
    ii. Display each sub-menu one at a time and let the diner make a selection from each by inputting an item number as shown in the sub-menus in step 3. Your program should validate each input (item numbers entered). Add the price of each item selected to the total price variable.
    iii. Once the current diner’s selections have been made display a list of all the items they selected. Don’t display the item if it is the first option: No selection.

    6. Finally, display the total price for all the food ordered by the group. Don’t add tax or a tip.

    7. All prices and the amount of the final bill should be displayed in standard dollars and cents format like $9.99 with exactly two decimal places.
    Last edited by eldeeb_hasan; April 9th, 2012 at 05:45 AM. Reason: had a problem pasting the tables

  6. #6
    Member
    Join Date
    Jan 2012
    Location
    Hellas
    Posts
    284
    Thanks
    11
    Thanked 59 Times in 57 Posts

    Default Re: Please help! Need help with class project!

    Where are you stuck? Which part is giving you trouble? Do you have any specific questions?
    And please use the highlight tags for better readability.

  7. #7
    Junior Member
    Join Date
    Apr 2012
    Posts
    5
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please help! Need help with class project!

    Quote Originally Posted by andreas90 View Post
    Where are you stuck? Which part is giving you trouble? Do you have any specific questions?
    And please use the highlight tags for better readability.
    I'm stuck on how to keep the program looping for the number of diners inputted to the int peopleInGroup, and also I'm not sure if I should use a switch or not for the appetozer, entree, etc. selections.

    Also, I've highlighted the parts that I'm stuck on or not sure about.

    Thanks.

  8. #8
    Junior Member
    Join Date
    Apr 2012
    Location
    Missouri, United States
    Posts
    17
    Thanks
    4
    Thanked 2 Times in 2 Posts

    Default Re: Please help! Need help with class project!

    I spotted this slight problem with the initializing of "i" and two of your array variables:
    int i = 1;
    int [] appetizerChoice = new int [i];
     
    			int [] entreeChoice = new int [i];
    Int "i" should start at 0. Also, instead of having the size of the arrays be "i", their size should be "peopleInGroup".

    With the change to "i", the code in your first hightlight should be changed as follows:
    while(i < peopleInGroup)
    			{
     
    				while (appetizerChoice[i] < 1 || appetizerChoice[i] > 5)
    				{

    After those fixes, the code looks like it should work. It seems like you're on the right track for your assignment.
    Last edited by Gigggas; April 10th, 2012 at 12:40 AM.

Similar Threads

  1. [SOLVED] FREE HELP WANTED: Setting up Class structure for Gui(JFrame) project.
    By JonLane in forum Object Oriented Programming
    Replies: 2
    Last Post: February 21st, 2012, 02:19 AM
  2. [SOLVED] Project help...confusion with changing a getter/setter for a driver class
    By coolidge in forum Java Theory & Questions
    Replies: 1
    Last Post: September 30th, 2011, 11:08 PM
  3. Replies: 7
    Last Post: July 21st, 2011, 02:29 PM
  4. Help requested - testing a class with a tester class, no methods allowed.
    By miketeezie in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 21st, 2011, 10:40 PM
  5. [SOLVED] Return randomized String to other class in project
    By Fermen in forum Collections and Generics
    Replies: 2
    Last Post: February 16th, 2011, 05:36 PM