Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create an application that allows you to enter student data that consists of an

ID: 3683129 • Letter: C

Question

Create an application that allows you to enter student data that consists of an ID number, first name, last name, and grade point average. Depending on whether the student's grade point average is at least 2.0, output each record either to a file of students in good standing or those on academic probation. Save the program as StudentsStanding.java. b. Create an application that displays each record in the two files created in the Students Standing application in Exercise 8a. Display a heading to introduce the list produced from each file. For each record, display the ID number, first name, last name, grade point average, and the amount by which the grade point average exceeds or falls short of the 2.0 cutoff. Save the program as StudentsStanding2.java.

Explanation / Answer

StudentsStanding.java


import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class StudentsStanding {

   /**
   * @param args
   */
   public static void main(String[] args) throws IOException {
       // TODO Auto-generated method stub
       java.util.Scanner in = new java.util.Scanner(System.in);
       File file1=new File("GoodStanding.txt");
       File file2=new File("Probation.txt");
       FileWriter fw1 = new FileWriter(file1);
       FileWriter fw2 = new FileWriter(file2);
       String firstName;
       String lastName;
       int id;
       double averageGrade;
       String str1 = "", str2 = "";
       while(true){
       System.out.println("Please enter ID: ");
       id = in.nextInt();
       System.out.println("Please enter First Name: ");
       firstName = in.next();
       System.out.println("Please enter Last Name: ");
       lastName = in.next();
       System.out.println("Please enter averageGrade: ");
       averageGrade = in.nextDouble();
       if(averageGrade >= 2.0){
       str1 = str1 + id +" "+firstName+" "+lastName+" "+averageGrade+" ";
       }
       else{
       str2 = str2 + id +" "+firstName+" "+lastName+" "+averageGrade+" ";  
       }
       System.out.println("Please press q for quit or press any character for continue...");
       char c = in.next().charAt(0);
       if(c == 'q' || c == 'Q'){
           fw1.write(str1);
           fw1.flush();
           fw1.close();
           fw2.write(str2);
           fw2.flush();
           fw2.close();              
           System.out.println("Data has been stored");
           break;
       }
       }

   }

}

Output:

Please enter ID:
111
Please enter First Name:
Suresh
Please enter Last Name:
Murapaka
Please enter averageGrade:
1.9
Please press q for quit or press any character for continue...
1
Please enter ID:
222
Please enter First Name:
Sekhar
Please enter Last Name:
Murapaka
Please enter averageGrade:
3.0
Please press q for quit or press any character for continue...
1
Please enter ID:
333
Please enter First Name:
Anshu
Please enter Last Name:
Murapaka
Please enter averageGrade:
4.0
Please press q for quit or press any character for continue...
1
Please enter ID:
444
Please enter First Name:
Revathi
Please enter Last Name:
Kella
Please enter averageGrade:
1.8
Please press q for quit or press any character for continue...
q
Data has been stored

StudentsStanding2.java


import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class StudentsStanding2 {

   /**
   * @param args
   */
   public static void main(String[] args) throws IOException {
       // TODO Auto-generated method stub
       File file1=new File("GoodStanding.txt");
       File file2=new File("Probation.txt");
       System.out.println("-------------------- Grade Point Average greater than or equal to 2.0 Records -----------------");
       if(file1.exists()){
           BufferedReader br = new BufferedReader(new FileReader(file1));
           String sCurrentLine;
           while ((sCurrentLine = br.readLine()) != null) {
               System.out.println(sCurrentLine);
           }  
           br.close();
          
       }
       else{
           System.out.println("File does not exist");
       }
       System.out.println("-------------------- Grade Point Average less than 2.0 Records -----------------");
       if(file2.exists()){
           BufferedReader br = new BufferedReader(new FileReader(file2));
           String sCurrentLine;
           while ((sCurrentLine = br.readLine()) != null) {
               System.out.println(sCurrentLine);
           }  
           br.close();
          
       }
       else{
           System.out.println("File does not exist");
       }      
   }

}

Output:

-------------------- Grade Point Average greater than or equal to 2.0 Records -----------------
222   Sekhar   Murapaka   3.0
333   Anshu   Murapaka   4.0
-------------------- Grade Point Average less than 2.0 Records -----------------
111   Suresh   Murapaka   1.9
444   Revathi   Kella   1.8

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote