473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Help

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

Expand|Select|Wrap|Line Numbers
  1. import javax.swing.JOptionPane;
  2. public class CollegeAdmission
  3. {
  4.    public static void main(String args[])
  5.    { 
  6.      // Declare variables
  7.       String testScoreString;
  8.       String classRankString;
  9.       int testScore;
  10.       int classRank;
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.      // Get input and convert to correct data type
  22.  
  23.   {     input testScoreString = JOptionPane.showInputDialog("Enter testScore"); 
  24.          input classRankString = JOptionPane.showInputDialog("Enter ClassRank");
  25.         testScore = Integer.parseInt(testScoreString);
  26.           classRank = Integer.parseInt(classRankString);
  27.  
  28. }
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.      // test using admission requirements and print Accept or Reject 
  37.  
  38.  
  39. {    if( classRank >= 25)
  40.         {
  41.             System.out.println("Accept");
  42.         }
  43.     else
  44.        System.out.println("Reject"); 
  45.      }
  46.  
  47.  {   
  48.     if( testScore >= 80 )
  49.     {
  50.        if( classRank >= 50 )
  51.           System.out.println("Accept");
  52.        else
  53.           System.out.println("Reject");
  54.     }
  55.     else
  56.     {
  57.            if( testScore >= 70 )
  58.        {
  59.         if( classRank >=75 ) 
  60.            System.out.println("Accept");
  61.         else
  62.            System.out.println("Reject");
  63.        }
  64.        else
  65.     {    System.out.println("Reject");
  66.     }
  67.  
  68.  
  69.  
  70.  }  // End of main() method
  71.  
  72. } // End of CollegeAdmission class
  73. }
Feb 3 '09 #1
9 1343
JosAH
11,448 Expert 8TB
@blondee
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
Feb 3 '09 #2
jkmyoung
2,057 Expert 2GB
My guess based on your code would be:
testScore = Integer.parseInt(testScoreString);

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.
Feb 3 '09 #3
JosAH
11,448 Expert 8TB
@jkmyoung
That's not it; the NumberFormatException extends the RuntimeException 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
Feb 3 '09 #4
tahira
6
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
Feb 7 '09 #5
r035198x
13,262 8TB
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?
Feb 9 '09 #6
tahira
6
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
Feb 9 '09 #7
JosAH
11,448 Expert 8TB
@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.
Feb 9 '09 #8
tahira
6
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
Feb 9 '09 #9
r035198x
13,262 8TB
Read Jos' reply (#8) above again.
Feb 10 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help...
9
by: Tom | last post by:
A question for gui application programmers. . . I 've got some GUI programs, written in Python/wxPython, and I've got a help button and a help menu item. Also, I've got a compiled file made with...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
3
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With...
7
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available...
5
by: Steve | last post by:
I have written a help file (chm) for a DLL and referenced it using Help.ShowHelp My expectation is that a developer using my DLL would be able to access this help file during his development time...
8
by: Mark | last post by:
I have loaded Visual Studio .net on my home computer and my laptop, but my home computer has an abbreviated help screen not 2% of the help on my laptop. All the settings look the same on both...
10
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably...
1
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve...
0
by: hitencontractor | last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003. I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About. The application...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.