I need to finish it ASAP

1. Read students’ marks and Name: for each student read his/her name and then read his/her marks (first-test mark (/15), Mid-term mark (/20), Lab-test mark (/15) and Final mark (/50)).Store these data in two-dimensional parallel arrays: NAMES, MARKS.

2. Calculate the total mark for each of all students entered. Store these marks in another parallel array TOTAL.

3. Convert total marks to character grades (F, D, C, B, A). These grades will be stored in an additional parallel array GRADES.

4. Calculate and return the best mark and the before best.

5. Calculate and return the lowest mark, the before lowest mark.

6. Calculate and return the average mark between all the total marks.

7. Calculate and return the number of students getting each of these grades (F, D, C, B, A).

8. Display the students’ name with the best and before best marks.

9. Display the students’ name with the lowest and before lowest marks.

10. Display the number of students getting each of these grades (F, D, C, B, A).

11. Display the average mark between all these total marks.

Note: this what i get until this time.....

import java.io.*;
public class Students
{
    static public void main (String args[ ]) throws IOException
    {
        int student;
        int numberOfStudents = 0;
        double mark, average, sum = 0;
        String studentString ="";
        String nameString, markString;
        final String TERMINATE = "end";
        final int NUMBER_OF_MARKS = 5;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


        System.out.println("How many student's 5-mark average will you be calculating?");
        numberOfStudents = getNumberFromUser();
        String[] studentNames = new String[numberOfStudents];
        int[] results = new int[numberOfStudents];

        for(int i = 0; i< numberOfStudents; i++)// Loop 1 gets the names
        {
           System.out.println("What is your student's name? <Student 1 out of "+i+">");
           studentNames[i] =  br.readLine();
        }

        for(int i = 0; i< numberOfStudents; i++)// loop 2 gets the marks
        {
           System.out.println("Type in "+studentNames[i]+" s average one at a time <Average will be calculated>");
           int total = 0;
           for(int j = 0; j < NUMBER_OF_MARKS; j++ ) // inner loop to get each mark
           {
              total = total + getNumberFromUser();
           }
           results[i] = total/NUMBER_OF_MARKS;
        }

        for (int i = 0; i<numberOfStudents; i++)// loop 3 prints averages
        {
           System.out.println( studentNames[i]+ "'s 5-mark average is "+results[i]);
        }

   }//End Main Method


   public static int getNumberFromUser() // new method to get numbers from user
   {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int myNumber = 0;
        try
        {
           String fromUser = br.readLine();
           myNumber = Integer.parseInt(fromUser);
        }
        catch(java.lang.NumberFormatException nfe)
        {
            System.out.print("Please enter a valid number");
            return getNumberFromUser();
        }
        catch(java.io.IOException ioe)
        {
           System.out.println("Check Keybord Settings");
        }
        if(myNumber <1)
        {
           System.out.print("Please enter a valid positive number");
           return getNumberFromUser() ;
        }
        else
        {
           return myNumber;
        }
   }


}/

but still i don't know where and how to input the calcute the grade........

Edited 6 Years Ago by shhfrlsk06: n/a

Because you have created a small C program using Java. Do not simply put everything in the main method. You need to essentially throw this away and start again. Create a class that holds the varying pieces of information as instance variables and that defines methods to do those operations above.

well, this maybe because i usually do programming using C..
can u try to explain a little bit more..
i really need help on this.

by the way, i found this coding..
is it as you told?

class Student
{
// data members
private String _studentNumber;
private String _studentName;
private int _markForMaths;
private int _markForEnglish;
private int _markForScience;
// Set Student Name
public void setStudentName(String studentName)
{
_studentName = studentName;
}
// Set the student number
public void setStudentNumber(String studentNumber)
{
_studentNumber = studentNumber;
}
// getNumber()
// return student number
public String getNumber()
{
return _studentNumber;
}
// getName()
// return student name
public String getName()
{
return _studentName;
}
// entermarks()
// enter all subject marks given as args
public void enterMarks(int maths, int english, int science)
{
_markForMaths = maths;
_markForEnglish = english;
_markForScience = science;
}
// getMathsMark()
// return mark for maths
public int getMathsMark()
{
return _markForMaths;
}
// getEnglishMark()
// return mark for English
public int getEnglishMark()
{
return _markForEnglish;
}
// getScienceMark()
// return mark for Science
public int getScienceMark()
{
return _markForScience;
}
// calculateAverageMark()
// return the average of the three marks
public double calculateAverageMark()
{
return ((_markForMaths + _markForEnglish +
_markForScience) / 3.0);
}
}
// class StudentTester
// tests the Student class above
class StudentTester
{
public static void main(String[] args)
{
String stud_num, stud_name;
Student s1 = new Student();
Student s2 = new Student();
s1.setStudentName("Britney Spears");
s1.setStudentNumber("11111");
s1.setStudentName("Eddie Vedder");
s1.setStudentNumber("22222");
s1.enterMarks(20, 60, 2);
s2.enterMarks(80, 75, 76);
outDetails(s1);
outDetails(s2);
}
// Write the details to standard out
public static void outDetails(Student s)
{
System.out.println("--------------------------");
System.out.println("Student Number:\t" + s.getNumber());
System.out.println("Student Name:\t" + s.getName());
System.out.println("Maths:\t\t" + s.getMathsMark());
System.out.println("English:\t" + s.getEnglishMark());
System.out.println("Science:\t" + s.getScienceMark());
System.out.println("Average:\t" +
s.calculateAverageMark());
}
}
This article has been dead for over six months. Start a new discussion instead.