Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   tried so hard.. still not working .. its just a simple program (http://www.go4expert.com/forums/tried-hard-simple-program-t25238/)

thila 13Mar2011 23:40

tried so hard.. still not working .. its just a simple program
 
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?

shabbir 14Mar2011 07:16

Re: tried so hard.. still not working .. its just a simple program
 
It really works but may be not as you expect it. What do you expect it to work like?

virxen 17Mar2011 01:33

Re: tried so hard.. still not working .. its just a simple program
 
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);
    }
   
 
 }



All times are GMT +5.5. The time now is 12:10.