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 391,944 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 3,882 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: 2931 | Replies: 3
Reply
Join Date: Jul 2005
Posts: 9
Reputation: Java John needs is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Java John needs Java John needs is offline Offline
Newbie Poster

News JAVA program help (Student/Grades)

  #1  
Jul 8th, 2005
Hey to everyone out there. I am new to this forum and seeking assistance with a java program assignment. if anyone can help let me know. The program is completed all I have left is to produce accurate output of a students grade. Here is the code:

////////////////////////////////////////////////////////////////

import javax.swing.JOptionPane;
class Student {
final double ASSIGNMENT_ONE_PERCENTAGE = .10;
final double ASSIGNMENT_TWO_PERCENTAGE = .10;
final double ASSIGNMENT_THREE_PERCENTAGE = .10;
final double ASSIGNMENT_FOUR_PERCENTAGE = .10;
final double MIDTERM_PERCENTAGE = .25;
final double FINALEXAM_PERCENTAGE = .25;
final double PARTICIPATION_PERCENTAGE = .10;

String name, finalLetterGrade;
int assignmentOne = 0;
int assignmentTwo = 0;
int assignmentThree = 0;
int assignmentFour = 0;
int midterm = 0;
int finalExamGrade = 0;
int participation = 0;
double finalNumericGrade = 0;


public Student() {
System.out.println (" Initializing Student...");

}

public void inputGrades() {
name=JOptionPane.showInputDialog("Enter Student's full Name:");
assignmentOne = Integer.parseInt(JOptionPane.showInputDialog( "Enter the Assignment One Grade" ));
assignmentTwo = Integer.parseInt(JOptionPane.showInputDialog( "Enter the Assignment Two Grade" ));
assignmentThree = Integer.parseInt(JOptionPane.showInputDialog( "Enter the Assignment Three Grade" ));
assignmentFour = Integer.parseInt(JOptionPane.showInputDialog( "Enter the Assignment Four Grade" ));
midterm = Integer.parseInt(JOptionPane.showInputDialog( "Enter the Midterm Grade" ));
finalExamGrade = Integer.parseInt(JOptionPane.showInputDialog( "Enter the Final Examination Grade" ));
participation = Integer.parseInt(JOptionPane.showInputDialog( "Enter the Participation Grade" ));
}

public double getAverage(){
finalNumericGrade =
(assignmentOne * ASSIGNMENT_ONE_PERCENTAGE) +
(assignmentTwo * ASSIGNMENT_TWO_PERCENTAGE) +
(assignmentThree * ASSIGNMENT_THREE_PERCENTAGE) +
(assignmentFour * ASSIGNMENT_FOUR_PERCENTAGE) +
(midterm * MIDTERM_PERCENTAGE) +
(finalExamGrade * FINALEXAM_PERCENTAGE) +
(participation * PARTICIPATION_PERCENTAGE);
return finalNumericGrade;
}

private String letterGrade(){
if (finalNumericGrade >= 93)
finalLetterGrade = "A";
else
if ((finalNumericGrade >= 85) & (finalNumericGrade < 93))
finalLetterGrade = "B";
else
if ((finalNumericGrade >= 78) & (finalNumericGrade < 85))
finalLetterGrade = "C";
else
if ((finalNumericGrade >= 70) & (finalNumericGrade < 78))
finalLetterGrade = "D";
else
if (finalNumericGrade < 70)
finalLetterGrade = "F";

return finalLetterGrade;



}


public String toString() {
String studentStringValue= " Student Name is: "+name +"\n";
studentStringValue+= " Assignment One grade is: " + assignmentOne + "\n";
studentStringValue+=" Assignment Two grade is: " + assignmentTwo + "\n";
studentStringValue+=" Assignment Three grade is: " + assignmentThree + "\n";
studentStringValue+=" Assignment Four grade is: " + assignmentFour + "\n";
studentStringValue+=" Midterm grade is: " + midterm + "\n";
studentStringValue+=" Final Exam is: " + finalExamGrade + "\n";
studentStringValue+=" Participation grade is: " + participation + "\n\n";
studentStringValue+=" Final Numeric Grade is: " + finalNumericGrade + "\n";
studentStringValue+=" Final Letter Grade is: " + finalLetterGrade +"\n";

return studentStringValue;
}


public void printName(){
System.out.print(" "+name);
}

}

////////////////////////////////////////////////////////////////

I can not get the letter grade to reflect in the output. ANy ideas?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2005
Location: Planet Earth
Posts: 26
Reputation: darklordsatan is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
darklordsatan's Avatar
darklordsatan darklordsatan is offline Offline
Light Poster

Re: JAVA program help (Student/Grades)

  #2  
Jul 8th, 2005
Could you post the sources of the class where you instanciate Student and call the methods?
Reply With Quote  
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: JAVA program help (Student/Grades)

  #3  
Jul 8th, 2005
I JUST gave you the answer to this problem a couple of days ago. Your program works fine...Nowhere in your code do you actually run the program though..What do you expect it do output if you don't make it output.

This is the link...Don't crosspost. If you have further questions let me know, but your code DOES work fine and will output the grades if you add the output lines like I gave you.

http://daniweb.com/techtalkforums/thread27345.html
Reply With Quote  
Join Date: Jul 2005
Posts: 9
Reputation: Java John needs is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Java John needs Java John needs is offline Offline
Newbie Poster

Re: JAVA program help (Student/Grades)

  #4  
Jul 21st, 2005
Server Crash, Thanks. Your responses helped out.
Reply With Quote  
Reply

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

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

 

DaniWeb Java Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

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