Results 1 to 8 of 8
- 05-10-2010, 06:36 PM #1
Member
- Join Date
- May 2010
- Location
- nj
- Posts
- 3
- Rep Power
- 0
Help with calculation for final grade of student
i need help writing this program. i'm new and i need someone to check out these instructions and figure out how to write it. here is what i have , but it is not write can u help me?
The calculation for the final grade of a student is: homework score plus project score plus test score plus exam score. If the final grade is 70 or over the student is rated as PASS. If the final grade is less than 70 the student is rated as FAIL
Design a computer program to calculate the final grade of one or more students using the formula above. Determine if the student passed or failed. Display the student’s name, final grade, and PASS/FAIL rating..
Design the program so that it loops for any number of students, that is the program sequence needs to repeat for each set of data.
Some sample data are as follows:
Name homework project test exam
Mary 27 15 25 25
Pete 22 14 23 24
Bimbo 10 6 15 10
** this is what I written so far....
/* Project 2 student final grade */
import java.io.*;
import java.lang.*;
import java.text.*;
import java.util.*;
//Set up public class
public class Grade
{
//declare main() method
public static void main(String[] args) throws IOException
{
//Declare data types
float name,homework,project,test,exam,FinalGrade;
int finalgrade = 70;
if (finalgrade ==70)
{
System.out.println("\n pass");
}else{
System.out.println("\n fail");
}
//set up input stream
Scanner readin = new Scanner(System.in);
System.out.println("\n Enter 1 for student name , 2 for no more data");
choice = readin.nextInt();
while (choice <2)
{
if (choice ==1)
{
// student name here
//prompt for homework
System.out.println("\n\n enter score of homework");
//stream in homework and convert to float
homework = readin.nextFloat();
//prompt for project
System.out.println("\n\n enter score of project");
//stream in project and convert to float
project = readin.nextFloat();
// prompt for test
System.out.println("\n\n enter score of test");
// stream in test and convert to float
test = readin.nextFloat();
// prompt for exam
System.out.println("\n\n enter score of exam");
exam = readin.nextFloat();
//Calculate results
Final Grade = (homework+project+test+exam);
//prepare data for out put display
System.out.print("\n\nThe results of the calcuations are\n\n\n");
System.out.println("the Final Grade is:\t\t" + (FinalGrade));
}// end 1st if
if (choice == 2)
{// end 2nd if
System.out.println("\n Enter 1 for student name , 2 for no more data");
// input choice
}
choice = readin.nextInt();
}// end while loop
}// end main
}// end class
- 05-10-2010, 06:48 PM #2
Senior Member
- Join Date
- Feb 2010
- Location
- Ljubljana, Slovenia
- Posts
- 470
- Rep Power
- 4
Ok, first of all, code tags and proper indentation makes people more likely to help you. Next, float name? Unless people are named 3,14 and 0,5431 I don't see how that would work. A good OOP approach would be to create a class called Student, with a String name (!), and int values for grades (unless they can have fractions of a grade, in that case floats are ok), with a method called calcFinalGrade() that returns the grade, and a boolean pass() method which returns true if the final grade is over 70.
Ever seen a dog chase its tail? Now that's an infinite loop.
- 05-10-2010, 06:59 PM #3
Member
- Join Date
- May 2010
- Location
- nj
- Posts
- 3
- Rep Power
- 0
can u right the code for me then explain it to me? im a noob
- 05-10-2010, 07:01 PM #4
Senior Member
- Join Date
- Feb 2010
- Location
- Ljubljana, Slovenia
- Posts
- 470
- Rep Power
- 4
I don't mean to come across as harsh, but this problem is made for "noobs" to get a grasp on the basics. It just requires the addition of a few values ,a check and a loop. Try to do it yourself, and generally speaking, begging for homework is frowned upon.
Ever seen a dog chase its tail? Now that's an infinite loop.
- 05-10-2010, 07:16 PM #5
!! your code is a mess !! its all out of order! why do you have an if statement at the top? why are you using floats!?
I suggest buying a book.:rolleyes: ~ Sno ~ :rolleyes:
'-~ B.S. Computer Science ~-'
- 05-10-2010, 07:27 PM #6
Member
- Join Date
- May 2010
- Location
- nj
- Posts
- 3
- Rep Power
- 0
lol, ill fix it and show u guys. It could take a while because of my job.
-
- 05-10-2010, 11:49 PM #8
Member
- Join Date
- May 2010
- Posts
- 23
- Rep Power
- 0
Similar Threads
-
Array highest grade
By Cdlove in forum New To JavaReplies: 5Last Post: 05-05-2010, 09:25 PM -
Grade my questions, lol
By syntrax in forum New To JavaReplies: 4Last Post: 12-16-2009, 06:03 AM -
Help with JAVA (Grade Book)
By Sara_21 in forum New To JavaReplies: 3Last Post: 11-30-2009, 02:45 PM -
beginner grade 11-need help with RaceCar Game
By bobmasta5 in forum New To JavaReplies: 0Last Post: 01-09-2009, 09:04 PM -
[SOLVED] is final class members are also final ?
By haoberoi in forum New To JavaReplies: 4Last Post: 11-10-2008, 03:01 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks