Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
    Bookmark Topic Watch Topic
  • New Topic

Pls help on this read Input

 
Jeannie Kaw
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi everybody,
I need ur assistance, as this program have errors, which i unable to correct it.
Appreciate your assistance on this matter.
Create a record contains 15 students and read the input from user.
1) We are free invited to enter the details of a Student with the name,and enter the 3 Marks obtained in each 3 subjects. (like..Integer.parseInt(input);read their input)
2) Compute the average score for each student, then display the highest average score and lowest average score.
Develop in Application and print out the input from what user entered.
Below is the source code
==================================================

//run this program as GoodLuck.java
import java.io.*;
import java.lang.*;
class GoodLuck
{
public static void main(String args[]) throws IOException
{
String[] name = new String[15];
int[] students = new int[15];
String Studname;
int mark1, mark2, mark3;

BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter your Name:");
System.out.println("Enter your mark1");
System.out.println("Enter your mark2");
System.out.println("Enter your mark3");

for(int i =0; i <=14; i++)
{
Studname = input.readLine();
mark1= Integer.parseInt(input.readLine());
mark2= Integer.parseInt(input.readLine());
mark3= Integer.parseInt(input.readLine());
name[i] =Studname;
students[i] = mark1;
students[i] = mark2;
students[i] = mark3;

};
double highestAvg = -1.0;
double lowestAvg = 101.0;


for (int i = 0; i < students.length; i++)

for (int i = 0; i < students.length; i++)
{
double avg = (students[i].mark1 + students[i].mark2 +
students[i].mark3) / 3.0;
if (avg > highestAvg)
highestAvg = avg;
if (avg < lowestAvg)
lowestAvg = avg;
System.out.print (students[i].name + " " +
students[i]+ " " +
students[i]+ " " +
students[i]+ " " + avg + " ");
if (avg < 40)
System.out.println ("FAIL");
else
if (avg < 60)
System.out.println ("PASS");
else
if (avg < 70)
System.out.println ("CREDIT");
else
System.out.println ("DISTINCTION");
}
System.out.println ();

System.out.println ("Highest Average = " + highestAvg);
System.out.println ("Lowest Average = " + lowestAvg);
}
}
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Report post to moderator
respond in this thread. We are still waiting for your response there to tell us the problem you are having.
Jamie
 
    Bookmark Topic Watch Topic
  • New Topic