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 2 of 2

Thread: my menu doesnt work can u tell me whats wrong

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default my menu doesnt work can u tell me whats wrong

    // The "Final_Project" class.
    import java.awt.*;
    import hsa.Console;
    import java.util.Random;
    public class Final_Project
    {
        static Console c;           // The output console
     
        public static void main (String[] args)
        {
            c = new Console ();
     
     
            int w ;
            String answer;
     
     
          char answer1 = 'y';
          char answer2 = 'n';
     
     
     
     
          while (answer2=='n')
          { 
                c.clear();
     
                //main menu 
                c.setColor(Color.red);
                c.fillRect(1,1,100,125); 
                c.fillRect(1,10,100,1000);
     
     
                c.println("Main Menu");   
                c.println("welcome please enter which piece you would like to view"); 
                c.println("\n\nto see the number manipulator press 1");  
                c.println("to see the game press 2");
                c.println("to see the string manipulator press 3");
                c.println("to see the animation press 4");  
                c.println("to close the program press 5");  
     
                w=c.readInt();
     
                c.clear(); 
     
     
     
     
     
                    // Triangle sides
                    if (w==1)
                    {  
                        while (answer1=='y')
                        {
                        c.clear(); 
                        double a,b,d,t,e,f,g,h,s;
     
                        c.println("welcome this is to show the area of a triangle using herons theory");
     
     
                        c.println("hello please enter the three sides of your triangle.");
     
     
                        a = c.readInt();
                        b = c.readInt();  
                        d = c.readInt(); 
                        t = (a+b+d);
                        s = ((a+b+d)/2);
     
                        e = (s-a);
                        f = (s-b);
                        g = (s-d);
                        h = (s*(e*f*g));
     
     
     
                        c.println("the perimeter of your triangle is " + t);  
                        c.println("the equation to use herons theory for s is s=(a+b+c)/2");   
                        c.println(s+ " this is half of your perimeter");   
                        c.println("so the area of your trianle would be "+Math.sqrt(h)); 
                        c.println("to continue press y to exit press n");
                        answer1=c.getChar();
                        }
                  }
     
     
     
     
     
     
     
     
          if  (w==2)
          {
                while (answer1 == 'y')
                {
                    Random dice = new Random ();
                    int num1,num2;
                    c.println("this is a dice game every time the roll is equal to 2 it prints snake eyes every time it adds to 7 it prints lucky seven");
                    for ( int counter = 1; counter <=100; counter++)
                    {
                        num1 = 1+dice.nextInt(6);
                        num2 = 1+dice.nextInt(6);
                        if (num1+num2==2)
                        {
                             c.print(num1+num2+"snake eyes ,");
                        }
                        else if(num1+num2==7) 
                        {
                            c.print(num1+num2+"lucky seven ,");
                        }
                        else
                        {
                            c.print(num1+num2+" ,");
                        }
                    }
          c.println("to continue press y to cancel press n");
          answer1=c.getChar();
                }
          }
     
     
     
     
     
     
     
          // String Manipulator
          if (w==3)
          { 
           while(answer1=='y')
              {
               int i,o ;
                String word;
                c.println("welcome this part of the program cncels out words that are four letters long ");
     
                for (i=1;i<6;i++)
                {
                    c.println("\nplease enter a word"); 
                    word = c.readString();
                    o=word.length();      
                    if(o == 4)
                    {     
                        c.print("XXXX");
                    }
     
                    else 
                    {
                        c.print(word);
                    }           
                }
               c.println("to continue press y to cancel press n");
               answer1=c.getChar();
               } 
          } 
     
     
     
     
          if(w==5)
          c.close();
         } 
     
           // Place your program here.  'c' is the output console
       } // main method
    } // Final_Project class
    Last edited by helloworld922; January 18th, 2010 at 01:24 PM.


  2. #2
    Member
    Join Date
    Feb 2010
    Location
    Dehradun, India
    Posts
    37
    Thanks
    1
    Thanked 7 Times in 6 Posts

    Default Re: my menu doesnt work can u tell me whats wrong

    What is hsa.console dear?

Similar Threads

  1. i'm new to java. whats is wrong in this code?
    By igorek83 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 30th, 2009, 07:38 PM
  2. JFrame, frame's title doesnt appear.
    By chronoz13 in forum AWT / Java Swing
    Replies: 1
    Last Post: November 26th, 2009, 02:38 PM
  3. whats wrong with this one....
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: October 6th, 2009, 10:08 AM
  4. help whats wrong
    By silverspoon34 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 3rd, 2009, 01:41 AM
  5. [SOLVED] whats wrong with my IDE
    By chronoz13 in forum Java IDEs
    Replies: 2
    Last Post: August 27th, 2009, 06:34 AM