Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • blondee
    New Member
    • Feb 2009
    • 1

    Help

    Hello,
    Can anyone help me with what is wrong with my code?

    Code:
    import javax.swing.JOptionPane;
    public class CollegeAdmission
    {
       public static void main(String args[])
       { 
         // Declare variables
    	  String testScoreString;
    	  String classRankString;
    	  int testScore;
    	  int classRank;
    		
    	   
    	  
    	  
         
    
    
    
    
         
         // Get input and convert to correct data type
    	  
      {     input testScoreString = JOptionPane.showInputDialog("Enter testScore"); 
    		 input classRankString = JOptionPane.showInputDialog("Enter ClassRank");
            testScore = Integer.parseInt(testScoreString);
    		  classRank = Integer.parseInt(classRankString);
    
    }
    
         
    
    
    
    
    
         // test using admission requirements and print Accept or Reject 
    
         
    {	if( classRank >= 25)
            {
         	   System.out.println("Accept");
            }
    	else
    	   System.out.println("Reject"); 
         }
    
     {   
    	if( testScore >= 80 )
    	{
    	   if( classRank >= 50 )
    	      System.out.println("Accept");
    	   else
    	      System.out.println("Reject");
    	}
    	else
    	{
               if( testScore >= 70 )
    	   {
    		if( classRank >=75 ) 
    		   System.out.println("Accept");
    		else
    		   System.out.println("Reject");
    	   }
    	   else
    	{	System.out.println("Reject");
    	}
    		        
      		  
          
     }  // End of main() method
      
    } // End of CollegeAdmission class
    }
    Last edited by JosAH; Feb 3 '09, 05:58 PM. Reason: added [code] ... [/code] tags
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by blondee
    Hello,
    Can anyone help me with what is wrong with my code?
    What's wrong with it? Does it compile? If not, what does the compiler say? (cut and paste please). If it does compile what does your program do what it isn't supposed to do? What is it supposed to do?

    kind regards,

    Jos

    Comment

    • jkmyoung
      Recognized Expert Top Contributor
      • Mar 2006
      • 2057

      #3
      My guess based on your code would be:
      testScore = Integer.parseIn t(testScoreStri ng);

      If the user doesn't enter an integer, it'll throw an error, and you seem to have no error checking, no try-catch.

      Otherwise, as stated above, you'll have to be specific about your problem.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by jkmyoung
        My guess based on your code would be:
        testScore = Integer.parseIn t(testScoreStri ng);

        If the user doesn't enter an integer, it'll throw an error, and you seem to have no error checking, no try-catch.

        Otherwise, as stated above, you'll have to be specific about your problem.
        That's not it; the NumberFormatExc eption extends the RuntimeExceptio n so you can get away with it without mentioning it in a throws clause. But again: the OP can't just dump a bunch of (badly formatted) code here, throw the hands up in the air and wait for a spoonfeeding solution.

        kind regards,

        Jos

        Comment

        • tahira
          New Member
          • Feb 2009
          • 6

          #5
          im new here first of all i intoduce my self , im student of c++ , and my exmaz are near , i ve joined acadmy to undersatnd this but im facing problem in undersatnding programs still. so i need ur help, experts plz meke me expert in progrmaing,
          i dont know how can i creat logic plz plz do reply me fast i will wait

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            At the top of the Java forum thread listing is a thread called "Read this first". It contains links that you need badly.
            P.S What is exmaz?

            Comment

            • tahira
              New Member
              • Feb 2009
              • 6

              #7
              first of all thnx for ur reply

              EXAMS means examination, final papers like final test

              i ve read that topic

              plz i want to understand it step by step
              when ever i open my book every program is different from other program
              make one simple program of if statement then understand me what is the first step

              waiting for ur reply

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                @tahira: unless your other handle is 'blondee' this is not your thread; hijacking someone else's thread is considered rude. You should've started your own thread instead of taking over this thread.

                kind regards,

                Jos (moderator)

                ps. This is the Java forum; for C and C++ questions there exists a C and C++ forum.

                Comment

                • tahira
                  New Member
                  • Feb 2009
                  • 6

                  #9
                  i m giving u one statment please make program according to statmeent then tell me how u hve make it

                  WRITE a program to get two numbers from keyboard during program execution. calculate the sum and product of the numbers and tehn print the result on the computer, ?

                  and also give me some sort of tips

                  thans in advance

                  Comment

                  • r035198x
                    MVP
                    • Sep 2006
                    • 13225

                    #10
                    Read Jos' reply (#8) above again.

                    Comment

                    Working...