Help with c++ grading program.

Help with java statement please?

  • Hi there this is a grading program eveythin here is working but i need help all the way on the botton i want to display the class average but for some reason it gives me errors at the time to compile..it says Points might not have initialized...can u help me please....very important for my assigment do tomorrow..:/ import java.util.*; public class Grading { public static void main(String[] args) { // main method //tell the user the name of this program System.out.print ("This is a Grading Program"); Scanner input = new Scanner(System.in); double Student_Grade,Class_Average; char letter; int Points,Total_Points, Students; int students, points, grade, percent; int k; String Initials; String initials, Grade; String format = " Student Initials Points Earned Total Percent Grade "; String Dashes = " ------------------ ------------- ------------- -------- "; // Prompt user to enter amount of Students is in the class System.out.println(" How many Studens are in the class?"); // Input the user for response Students = input.nextInt(); // Prompt user to enter total amount of points System.out.println(" What is the total amount of points?"); // Input users response Total_Points = input.nextInt(); // Print Sub Headings System.out.printf(format); // New line System.out.println(" "); // Print dashes System.out.println(Dashes); // New line System.out.println(); for(k=1; k<=Students; k++) // ask the user to get initials of student { System.out.println(" Enter students initials"); //input users response Initials = input.next(); // Get students total points System.out.println(" Enter student's point total"); // input users response Points = input.nextInt(); // students percent double Percent =100 * Points / Total_Points; double sum = 0.0; // Format Class table String Class_Table = " %5s %4d %4.2f %7s"; // get a new line System.out.println(); // Calculate Students letter grade Student_Grade = Points/2; if (Student_Grade >= 90) {Grade = "A";} else if(Student_Grade >= 80) {Grade = "B";} else if(Student_Grade >=70) {Grade = "C";} else if(Student_Grade >=60) {Grade = "D";} else {Grade ="F";} // Print Table System.out.printf(Class_Table, Initials,Points, Percent, Grade); System.out.println(); } // Class average if statement Student_Grade= 100 * Points / Total_Points; if (Student_Grade >= 90) {Grade="A";} else if (Student_Grade>= 80) {Grade="B";} else if (Student_Grade >= 70) {Grade="C";} else if (Student_Grade >= 60) {Grade = "D";} else {Grade = "F";} // // Print class average and letter grade System.out.println( "The Class average is" +Student_Grade/2+ Grade); }}// end of main method // end of class

  • Answer:

    Change this line: int Points,Total_Points, Students; to this line: int Points = 0,Total_Points = 0, Students;

Misiekj at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

I am afraid. You did not specify your problem clearly. Anyway, see the following. double total=0; for(k=1; k<=Students; k++){ System.out.println(" Enter students initials"); Initials = input.next(); System.out.println(" Enter student's point total"); Points = input.nextInt(); // students percent double Percent =100.0 * ( (double) Points) / ((double) Total_Points); total +=Percent; <-------------Total percent double sum = 0.0; <--------------what for // Format Class table String Class_Table = " %5s %4d %4.2f %7s"; // get a new line System.out.println(); // Calculate Students letter grade Student_Grade = Points/2; //Why to devide with 2? if (Student_Grade >= 90) Grade = "A"; else if(Student_Grade >= 80) Grade = "B"; else if(Student_Grade >=70)Grade = "C"; else if(Student_Grade >=60) Grade = "D"; else Grade ="F"; // Print Table System.out.printf(Class_Table, Initials,Points, Percent, Grade); System.out.println(); } //End of loop // Class average if statement total /=Students; // Print class average and letter grade System.out.println( "The Class average is" + total); }}// end of main method

James Bond

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.