| | |
calculate the grades for a student using if..else statements.
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2004
Posts: 16
Reputation:
Solved Threads: 0
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
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
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.
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. Java Syntax (Toggle Plain Text)
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
Dani the Computer Science Gal 
Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds

Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
•
•
Join Date: Jul 2004
Posts: 9
Reputation:
Solved Threads: 0
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");
}
}
}
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");
}
}
}
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)
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)
•
•
Join Date: Nov 2009
Posts: 19
Reputation:
Solved Threads: 0
0
#5 Nov 12th, 2009
java Syntax (Toggle Plain Text)
import java.util.Scanner; public class CaseGrade { public static void main(String[] args) { Scanner input = new Scanner (System.in); String name ; int grade; String exellent = "Exellent :"; String veryGgood ="Very Good :"; String good="Good :"; String pass ="Pass :"; String fail = "Fail :"; int max = 0; int min = 100; int sum = 0; int avg ; int counter =0; boolean repeat ; while (repeat =true) { System.out.println("Enter Name : "); name = input.next(); System.out.println("Enter Grade : "); grade = input.nextInt(); if (grade == -1 ) { avg = sum / counter; System.out.println(" result = :"); System.out.println(exellent +"\n"+ veryGgood +"\n"+ good +"\n"+ pass +"\n"+fail); System.out.println("maximum = "+ max +"\t"); System.out.println("minimum = "+ min +"\t"); System.out.println("\tAverage = " +avg); System.exit(0); } switch (grade/10) { case 100: case 9 : exellent += "\n"+ name + "\t" +grade+"\n"; break; case 8 : veryGgood += "\n" + name + "\t" +grade +"\n"; break ; case 7 : good += "\n" + name + "\t" +grade +"\n"; break; case 6: case 5: pass += "\n" + name + "\t" +grade +"\n"; break; default: fail +="\n" + name + "\t" +grade +"\n"; break; } sum = sum + grade; counter = counter + 1; if (grade > max) { max = grade; } if (grade < min) { min = grade; } } } }
Last edited by peter_budo; Nov 12th, 2009 at 8:48 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
0
#6 Nov 12th, 2009
saadismail85 please use code tags and/or start a new thread.
For code tags click the button: [code] when you write your post
For code tags click the button: [code] when you write your post
Check out my New Bike at my Public Profile at the "About Me" tab
-1
#9 34 Days Ago
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
0
#10 34 Days Ago
Java Syntax (Toggle Plain Text)
while (repeat =true)
Last edited by ithelp; 34 Days Ago at 7:50 am.
![]() |
Similar Threads
- Student Grade Programming (C++)
- Please help me!! (C++)
- Student Grades & Structs (C++)
- Calculate Students Grade And Grade Weightage (ColdFusion)
- grades.java -- help!! (Java)
Other Threads in the Java Forum
- Previous Thread: How To Extract A Value from JTextField and Display The BookID at JList In The Same GU
- Next Thread: applets in terminal window
| Thread Tools | Search this Thread |
Tag cloud for Java
-xlint 2dgraphics android api apple applet application applications arguments array arrays automation bank bidirectional binary bluetooth chat class classes client code collision component database db development draw eclipse eclipsedevelopment error event exception file fractal game givemetehcodez graphics gui helpwithhomework homework html ide image input integer integration j2me jarfile java javadesktopapplications javafx javaprojects jmf jni jpanel julia learningresources linux list loop map method methods mobile netbeans newbie number oracle print problem program programming project projectideas recursion researchinmotion scanner screen server service set size sms socket sort sorting sql sqlserver state string swing swt tcp test text-file threads time tree web windows






