Advertisement
Guest User

Untitled

a guest
Nov 21st, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.IOException;
  3. import java.util.Scanner;
  4. import java.io.FileReader;
  5. public class Ch9 {
  6.  
  7.     public static void main(String[] args) throws IOException {
  8.         // TODO Auto-generated method stub
  9. //      File file = new File("data.txt");
  10.        File file = new File("data.txt");
  11.        Scanner input = new Scanner(file); //new scanner input to collect data from existing file
  12.        String lastName;
  13.        String firstName;
  14.        char letterGrade;
  15.        int score;
  16.        Student[] Student = new Student[20];
  17.        
  18.        int i = 0;
  19.        while(i < 20)
  20.        {
  21.             lastName = input.next();
  22.             firstName  = input.next();
  23.             score = input.nextInt();
  24.            
  25.            Student[i] = new Student(lastName, firstName, score);
  26.            Student[i].setFirstName(firstName);
  27.            Student[i].setLastName(lastName);
  28.            Student[i].setScore(score);
  29.          
  30.            i++;
  31.        }
  32.        
  33.        for(int index = 0; index < 20; index++)
  34.        {
  35.            if(Student[index].getScore() >= 90)
  36.            {
  37.                letterGrade[index] = "A";
  38.            }
  39.        }
  40.        
  41.        
  42.        
  43.        for(int j = 0; j < 20 ; j++)
  44.        {
  45.        System.out.print(Student[j].getFirstName());
  46.        System.out.print(", ");
  47.        System.out.print(Student[j].getLastName());
  48.        System.out.println();
  49. //     System.out.println(Student[j].getScore());
  50.        }
  51.     }
  52.  
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement