Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.IOException;
- import java.util.Scanner;
- import java.io.FileReader;
- public class Ch9 {
- public static void main(String[] args) throws IOException {
- // TODO Auto-generated method stub
- // File file = new File("data.txt");
- File file = new File("data.txt");
- Scanner input = new Scanner(file); //new scanner input to collect data from existing file
- String lastName;
- String firstName;
- char letterGrade;
- int score;
- Student[] Student = new Student[20];
- int i = 0;
- while(i < 20)
- {
- lastName = input.next();
- firstName = input.next();
- score = input.nextInt();
- Student[i] = new Student(lastName, firstName, score);
- Student[i].setFirstName(firstName);
- Student[i].setLastName(lastName);
- Student[i].setScore(score);
- i++;
- }
- for(int index = 0; index < 20; index++)
- {
- if(Student[index].getScore() >= 90)
- {
- letterGrade[index] = "A";
- }
- }
- for(int j = 0; j < 20 ; j++)
- {
- System.out.print(Student[j].getFirstName());
- System.out.print(", ");
- System.out.print(Student[j].getLastName());
- System.out.println();
- // System.out.println(Student[j].getScore());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement