GradeHandlerOO

GradeHandlerOO - scholar[i].setExam1(num );...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * This program handles student grades */ import java.io.*; // Import all classes in java.io package. Saves typing. // the BufferedReaderClass we will use for keyboard // input is in this package public class GradeHandlerOO { p public static void main(String[] args) throws IOException { String line; // to hold user keyboard input double num = 0; // to hold the number converted from user input int i; int MAX; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); MAX = Integer.parseInt(args[0]); if (MAX <= 0) { System.out.println("command line needs to be positive integer"); return; } Student[] scholar; scholar = new Student[MAX]; for (i=0; i<scholar.length; i++) { // creat a new Student object // store it in the array scholar scholar[i] = new Student(); s System.out.print("Student name? "); line = in.readLine(); scholar[i].setName(line); System.out.println("grade 1? "); line = in.readLine(); num = Double.parseDouble(line);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: scholar[i].setExam1(num ); System.out.println("grade 2? "); line = in.readLine(); num = Double.parseDouble(line); scholar[i].setExam2(num ); s System.out.println("grade 3? "); line = in.readLine(); num = Double.parseDouble(line); scholar[i].setExam3(num ); }// end for /* printArray(grade1); System.out.println(); printArray(grade2); System.out.println(); printArray(grade3); System.out.println(); System.out.println("Largest grade, exam 1: "+ highest(grade1)); System.out.println("Student 1 avg: " + (grade1[0]+grade2[0]+grade3[0])/3); double sum = 0.0; for (i=0; i<MAX; i++) { sum = sum +grade2[i]; } double classAvg = sum/MAX; System.out.println("class avg exam 2: "+classAvg); */ }// end main method public static void printArray (double arr) { int i; for (i=0; i<arr.length; i++) { System.out.print(arr[i]+", "); } return; } } // end class...
View Full Document

This note was uploaded on 11/30/2009 for the course COMP 110 taught by Professor Stotts during the Spring '08 term at UNC.

Page1 / 2

GradeHandlerOO - scholar[i].setExam1(num );...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online