|
|
| OOP |
Expert:leshomo
i have problem with OOP hope u'll help me write a program that allows the user to enter student' names followed by their test scores and outputs the following information (assume that the maximum number of students in the class is 50); a Class average b Names of all the students whose test scores are below the class average, with an appropriate message c highest test score and names of all the students having the highes score
|
| Answers |
answer
|
answer
|
hi friend,
import java.io.*; import java.io.IOException; import java.util.*;
public class StudentInfor{
//public static void main(String args[]) throws IOException{
public static void main(String[] args) throws IOException {
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Student Information example"); Scanner input = new Scanner(System.in); //... These variables hold the max and min incomes. double maxnum = Double.MIN_VALUE; double minnum = Double.MAX_VALUE; int count = 0; double totalIncome = 0; //... Loop until negative number is entered. System.out.println("Enter student number."); while (input.hasNextDouble()) { //... Get the next value. double dou = input.nextDouble(); //... Compare this value to max and min. Replace if needed. if (dou > maxnum) { maxnum = dou; } if (dou < minnum) { minnum = dou; } //... Keep track of these values for average calculation. count++; totalIncome += dou; } if (count > 0) {
double average = totalIncome/ count;
System.out.println("Number of values = " + count); System.out.println("Maximum = " + maxnum); System.out.println("Minimum = " + minnum); System.out.println("Average = " + average); } else { System.out.println("Error: You entered no data!"); } } }
----------------------------
read for more information,
http://www.roseindia.net/java/master-java/java-object-oriented-language.shtml
|
| More Questions |
|
|
Post Answers
Ask Question
Facing Programming Problem?
|
|
|
|
|