User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 423,507 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,664 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 6364 | Replies: 3
Reply
Join Date: Jul 2004
Posts: 16
Reputation: shantuli is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
shantuli shantuli is offline Offline
Newbie Poster

Help calculate the grades for a student using if..else statements.

  #1  
Jul 25th, 2004
hi everyone,
i am very new in java. can anyone help me to solve the following problem:

A school conducts a 100 mark exam for its student and grades them as follows:
Grade:
Grade A: Marks>75
Grade B: 75>Marks>60
Grade C: 60>Marks>50
Grade D: 50>Marks>40

Write ajava program to calculate the grades for a student, using if..else statement. use some given value to test the code.

thank you,
regards,
shantuli
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,900
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 32
Solved Threads: 118
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: calculate the grades for a student using if..else statements.

  #2  
Jul 25th, 2004
I'm in a very giving mood today Usually I don't just give the answer to homework problems outright like I am now. I'd rather see some effort put in on your end. So consider yourself very lucky. The following is the pseudocode for the program. Think about what each line means, and then translate it into Java syntax line by line.

input student's grade
if grade < 100 AND grade > 75 { student got an A }
else if grade < 75 AND grade > 60 { student got a B }
else if grade < 60 AND grade > 50 { student got a C }
else if grade < 50 AND grade > 40 { student got a D }
else { student got an F } // didn't fit into any of the above scenerios, so must be an F
print to screen what the student got
Reply With Quote  
Join Date: Jul 2004
Posts: 6
Reputation: bobinson is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
bobinson bobinson is offline Offline
Newbie Poster

Re: calculate the grades for a student using if..else statements.

  #3  
Aug 4th, 2004
Hi shantuli,why not try this code as well.Have a lovely day.
Bobinson.



class Testy
{
byte score;


Testy()
{
score=78;
}


public static void main(String arg[])

{
Testy tst=new Testy();
tst.processGrades();
}

public void processGrades()
{


if
(score >=75)
{
System.out.println("Your grade is A");
}
else
if
((score >= 60)&&( score <75 ))
{
System.out.println("Your grade is B");
}
if
((score >=50 )&&(score<60))
{
System.out.println("Your grade is C");
}
else
if
((score >=40 )&&(score <50))
{
System.out.println(" Your grade is D");
}
else
if
(score <40 )
{
System.out.println(" Sorry you have no part here,FAILED");
}

}
}
Reply With Quote  
Join Date: Jul 2003
Location: Bamberg, Germany
Posts: 117
Reputation: Iron_Cross is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 2
Iron_Cross's Avatar
Iron_Cross Iron_Cross is offline Offline
Junior Poster

Re: calculate the grades for a student using if..else statements.

  #4  
Aug 4th, 2004
Dude, 2 things.
1. Put your code into the [*code] and [/code] tags (remove the * though)
2. Don't just give him the answer to his homework, what good will that do him. You can help him and give him clues, but don't just do it for him. Also, your code seems overly complicated and there is no room for adjustment (i.e. the grade is always 78)
elitehackers.info
Today's Penny-Arcade!
Pain is weakness leaving the body!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 4:27 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC