Java

Discussion in 'Java' started by andrew1993, Feb 5, 2012.

  1. andrew1993

    andrew1993 New Member

    Joined:
    Feb 5, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    /**
     * @(#)Botak James.java
     *
     *
     * @author 
     * @version 1.00 2011/12/6
     */
    
    import java.text.*;
    import java.util.*;
    
    public class BotakJames
    {
    static DecimalFormat fmt=new DecimalFormat("0.00");
    static Scanner input=new Scanner(System.in).useDelimiter("\r\n");
    static char appSelection=0;
    static char mainSelection=0;
    static char dessertSelection=0;
    static int counter=0;
    static double caesarSalad=2.50;
    static double soupOfTheDay=2.80;
    static double garlicBread=1.80;
    static double grilledFish=6.70;
    static double chickenChop=5.80;
    static double sirloinSteak=7.60;
    static double mangoPudding=2.80;
    static double iceCream=1.70;
    static double applePie=2.50;
    static double totalCost=0; 
    public static void main(String[]args) throws Exception 
    {
            
        	//declare variables
        	char appetizer;
        	char mainDish; 
        	char dessert;
        	char totalCost;
        	char exit;
            int choice;
        	
        do
        {
        		System.out.println("BOTAK JAMES MENU");
        		System.out.println("=================");
        		System.out.println("1.APPETIZER");
        		System.out.println("2.MAIN DISH");
        		System.out.println("3.DESSERT");
        		System.out.println("4.TOTAL COST");
        		System.out.println("5.EXIT");
        		System.out.println("**You can ONLY select one item from each category**");
        		System.out.print("Enter your choice:  ");
        		choice=input.nextInt(); 
        		switch(choice)
        		{
        	case 1: System.out.println("APPETIZER MENU");
        		    System.out.println("==============");
        		    System.out.println("1.CAESAR SALAD:\t"+"$2.50");
        		    System.out.println("2.Soup of the day:"+"$2.80");
        		    System.out.println("3.Garlic Bread:\t"+"$1.80");
        		    System.out.print("Enter choice:   "); 
        		    appSelection=(char)System.in.read();
        		    System.in.read();
         			System.in.read();
       				System.out.println();	
        		    {
        		    	if (choice>3)
        		    System.out.println("Error! Please pick your Appetizer");
        		    else if (choice==1)
        		    	System.out.println("You chose Caesar Salad");
        		    else if(choice==2)
        		    	System.out.println("You chose Soup of the day");
        		    else 
        		    	System.out.println("You chose Garlic Bread");
        		    }
        		    
        		    break;		
        	case 2: System.out.println("MAIN DISH MENU");
        		    System.out.println("--------------");
        		    System.out.println("1.GRILLED FISH\t"+"$6.70");
        		    System.out.println("2.CHICKEN CHOP\t"+"$5.80");
        		    System.out.println("3.SIRLOIN STEAK\t"+"$7.60");
        		    System.out.print("ENTER YOU CHOICE:  ");
        		    mainSelection=(char)System.in.read();
        		    System.in.read();
         			System.in.read();
       				System.out.println();
        		    {if (choice>3)
        		    System.out.println("Error! Please pick your Main Dish");
        		    else if (choice==1)
        		    	System.out.println("You chose GRILLED FISH");
        		    else if (choice==2)
        		    	System.out.println("You chose CHICKEN CHOP");
        		    else 
        		    	System.out.println("You chose SIRLOIN STEAK");
        		    	
        		    }
        		    break;
        	case 3: System.out.println("DESSERT MENU");
        		    System.out.println("------------");
        		    System.out.println("1.MANGO PUDDING\t"+"$2.80");
        		    System.out.println("2.ICE CREAM\t"+"$1.70");
        		    System.out.println("3.APPLE PIE\t"+"$2.50");
        		    System.out.println("ENTER YOUR CHOICE:");
        		    dessertSelection=(char)System.in.read();
        		    System.in.read();
         			System.in.read();
       				System.out.println();
        		    {
        		    if (choice>3)
        		    System.out.println("Error! Please pick your Dessert");
        		    else if (choice==1)
        		    	System.out.println("You chose MANGO PUDDING");
        		    else if (choice==2)
        		    	System.out.println("You chose ICE CREAM");
        		    else 
        		    	System.out.println("You chose APPLE PIE");
        		    	}
        		    break;
        	case 4: System.out.println("TOTAL COST");
        		    System.out.println("----------");
        		    if(counter==0)
        		    {
        		    	System.out.println("Nothing is selected");
        		    }	
        		    if (appSelection==0)
        		    {
        		   		System.out.println("No Appetizer ordered.");
        		     }
        		     else
        		     {
        		    System.out.println("For the Appetizer, you have ordered "+appSelection+fmt.format(appSelection));
        		     }
        		    if(mainSelection==0)
        		    {
        		    	System.out.println("No main dish ordered.");
        		    }
        		    else
        		    {
                       System.out.println("For the Main Dish, you have ordered"+mainSelection+fmt.format(mainSelection));
        		    }
        		    if(dessertSelection==0)
        		    {
        		    	System.out.println("No dessert ordered.");
        		    }
        		    else
        		    {	
        		    System.out.println("For the Dessert, you have ordered"+dessertSelection+fmt.format(dessertSelection));
        		    }
        		    //calculation 
        		   totalCost=(appSelection+mainSelection+dessertSelection);
        		    System.out.println(" The total bill is "+totalCost );
        		    break;
        	case 5: System.out.println("Thank you from for ordering from BOTAK JAMES");
        		    break;  
        		    default:System.out.println("Please enter correct choice.");
        		    break;	    
        		    	}
        	}while(choice!=5);	 
        		}
        	} 
    
    how to store the values in my menu? help me!!
     
    Last edited by a moderator: Feb 5, 2012
  2. andrew1993

    andrew1993 New Member

    Joined:
    Feb 5, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    My java !!

    Code:
    /**
     * @(#)Botak James.java
     *
     *
     * @author 
     * @version 1.00 2011/12/6
     */
    
    import java.text.*;
    import java.util.*;
    
    public class BotakJames
    {
    static DecimalFormat fmt=new DecimalFormat("0.00");
    static Scanner input=new Scanner(System.in).useDelimiter("\r\n");
    static char appSelection=0;
    static char mainSelection=0;
    static char dessertSelection=0;
    static int counter=0;
    static double caesarSalad=2.50;
    static double soupOfTheDay=2.80;
    static double garlicBread=1.80;
    static double grilledFish=6.70;
    static double chickenChop=5.80;
    static double sirloinSteak=7.60;
    static double mangoPudding=2.80;
    static double iceCream=1.70;
    static double applePie=2.50;
    static double totalCost=0; 
    public static void main(String[]args) throws Exception 
    {
            
        	//declare variables
        	char appetizer;
        	char mainDish; 
        	char dessert;
        	char totalCost;
        	char exit;
            int choice;
        	
        do
        {
        		System.out.println("BOTAK JAMES MENU");
        		System.out.println("=================");
        		System.out.println("1.APPETIZER");
        		System.out.println("2.MAIN DISH");
        		System.out.println("3.DESSERT");
        		System.out.println("4.TOTAL COST");
        		System.out.println("5.EXIT");
        		System.out.println("**You can ONLY select one item from each category**");
        		System.out.print("Enter your choice:  ");
        		choice=input.nextInt(); 
        		switch(choice)
        		{
        	case 1: System.out.println("APPETIZER MENU");
        		    System.out.println("==============");
        		    System.out.println("1.CAESAR SALAD:\t"+"$2.50");
        		    System.out.println("2.Soup of the day:"+"$2.80");
        		    System.out.println("3.Garlic Bread:\t"+"$1.80");
        		    System.out.print("Enter choice:   "); 
        		    appSelection=(char)System.in.read();
        		    System.in.read();
         			System.in.read();
       				System.out.println();	
        		    {
        		    	if (choice>3)
        		    System.out.println("Error! Please pick your Appetizer");
        		    else if (choice==1)
        		    	System.out.println("You chose Caesar Salad");
        		    else if(choice==2)
        		    	System.out.println("You chose Soup of the day");
        		    else 
        		    	System.out.println("You chose Garlic Bread");
        		    }
        		    
        		    break;		
        	case 2: System.out.println("MAIN DISH MENU");
        		    System.out.println("--------------");
        		    System.out.println("1.GRILLED FISH\t"+"$6.70");
        		    System.out.println("2.CHICKEN CHOP\t"+"$5.80");
        		    System.out.println("3.SIRLOIN STEAK\t"+"$7.60");
        		    System.out.print("ENTER YOU CHOICE:  ");
        		    mainSelection=(char)System.in.read();
        		    System.in.read();
         			System.in.read();
       				System.out.println();
        		    {if (choice>3)
        		    System.out.println("Error! Please pick your Main Dish");
        		    else if (choice==1)
        		    	System.out.println("You chose GRILLED FISH");
        		    else if (choice==2)
        		    	System.out.println("You chose CHICKEN CHOP");
        		    else 
        		    	System.out.println("You chose SIRLOIN STEAK");
        		    	
        		    }
        		    break;
        	case 3: System.out.println("DESSERT MENU");
        		    System.out.println("------------");
        		    System.out.println("1.MANGO PUDDING\t"+"$2.80");
        		    System.out.println("2.ICE CREAM\t"+"$1.70");
        		    System.out.println("3.APPLE PIE\t"+"$2.50");
        		    System.out.println("ENTER YOUR CHOICE:");
        		    dessertSelection=(char)System.in.read();
        		    System.in.read();
         			System.in.read();
       				System.out.println();
        		    {
        		    if (choice>3)
        		    System.out.println("Error! Please pick your Dessert");
        		    else if (choice==1)
        		    	System.out.println("You chose MANGO PUDDING");
        		    else if (choice==2)
        		    	System.out.println("You chose ICE CREAM");
        		    else 
        		    	System.out.println("You chose APPLE PIE");
        		    	}
        		    break;
        	case 4: System.out.println("TOTAL COST");
        		    System.out.println("----------");
        		    if(counter==0)
        		    {
        		    	System.out.println("Nothing is selected");
        		    }	
        		    if (appSelection==0)
        		    {
        		   		System.out.println("No Appetizer ordered.");
        		     }
        		     else
        		     {
        		    System.out.println("For the Appetizer, you have ordered "+appSelection+fmt.format(appSelection));
        		     }
        		    if(mainSelection==0)
        		    {
        		    	System.out.println("No main dish ordered.");
        		    }
        		    else
        		    {
                       System.out.println("For the Main Dish, you have ordered"+mainSelection+fmt.format(mainSelection));
        		    }
        		    if(dessertSelection==0)
        		    {
        		    	System.out.println("No dessert ordered.");
        		    }
        		    else
        		    {	
        		    System.out.println("For the Dessert, you have ordered"+dessertSelection+fmt.format(dessertSelection));
        		    }
        		    //calculation 
        		   totalCost=(appSelection+mainSelection+dessertSelection);
        		    System.out.println(" The total bill is "+totalCost );
        		    break;
        	case 5: System.out.println("Thank you from for ordering from BOTAK JAMES");
        		    break;  
        		    default:System.out.println("Please enter correct choice.");
        		    break;	    
        		    	}
        	}while(choice!=5);	 
        		}
        	} 
    i need to store values! Can help me store and edit?? thks!
     
    Last edited by a moderator: Feb 5, 2012
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Merged your both the threads. Avoid having the same thread over and over again.
     
  4. annahussy

    annahussy Banned

    Joined:
    Jun 20, 2012
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    My Java is a part of Java languages. It is quite difficult as easy also. You can learned it with so many options as well. I can suggest to choose the tutorial , which give you proper guidance regarding My Java. Thanks for your wonderful suggestions.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice