1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

tried so hard.. still not working .. its just a simple program

Discussion in 'Java' started by thila, Mar 13, 2011.

  1. thila

    thila New Member

    Joined:
    Mar 13, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    import java.io.*;
    Code:
     class pizza 
     { 
        public static void main (String[] args)  
       
        throws Exception 
        { 
           String use; 
           
           System.out.println("Large - L, "); 
           System.out.println(" Medium - M"); 
           System.out.println(" Small - S"); 
       
            
           BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); 
           use = bufferedReader.readLine(); 
             
      int tot=0; 
     int tota=0; 
     int Price1=0; 
      int Price2=0; 
      int Price3=0;   
      String S,M,L; 
         
     for(int i=0;i>=100;i++) 
        
      
      
     { 
             if(use.equals("S")) 
          
           {  
               Price1=550; 
           } 
         
          else if(use.equals("M")) 
             { 
                 Price2=800; 
             } 
           else if(use.equals("L")) 
           { 
               Price3=1200; 
           } 
          
           
          tota=tota+tot; 
           
        } 
        tot=Price1+Price2+Price3; 
         System.out.println("The total  price is");  
           System.out.println(tota); 
        } 
         
      
     } 
      
    why doesnt this work?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    It really works but may be not as you expect it. What do you expect it to work like?
     
  3. virxen

    virxen New Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    0
    try this

    Code:
    
    import java.io.*; 
    class pizza 
     { 
        public static void main (String[] args) throws Exception { 
           String use; 
           System.out.println("Large - L, "); 
           System.out.println(" Medium - M"); 
           System.out.println(" Small - S"); 
           BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); 
            long total=0; 
             for(int i=0;i<10;i++) {
                 System.out.println("give size(S,M, or L):");
                 use = bufferedReader.readLine(); 
                 int Price=0;
                  if(use.equalsIgnoreCase("S"))
                       Price=550;  
                   else if(use.equalsIgnoreCase("M")) 
                     Price=800; 
                   else if(use.equalsIgnoreCase("L")) 
                       Price=1200;
                   System.out.println("the size you have chosen costs "+Price) ;
                  total+=Price; 
            }  
             System.out.println("The total  price is "+total); 
        } 
         
      
     }
    
     

Share This Page