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

import java util. Scanner; import java.text. Decimal Format public class Assignm

ID: 3806990 • Letter: I

Question

import java util. Scanner; import java.text. Decimal Format public class Assignment5 public static void main (String args) Scanner console new Scanner (System.in); DecimalFormat fmt new Decimal Format 0.00") String choice; //Get a new student info. System.out.print ("InEnter name of the Student: String stuName consol e.nextLine System.out.print ("InEnter quality points earned: doubl e quality Pts console .nl ext Double System.out.print ("InEnter credit hours completed: int credithrs console .next Int //create a new Student object called 'stu1' with above input info //create the 2nd Student object called 'stu2' by using the default constructor //write code to change stu2 name to Jane Doe //call printMenu method to print the menu

Explanation / Answer

This is Student class:

package com.studentGrade;

public class Student {

   String stuName;
   double qualitPts;
   int credithrs;
   Course c;


   public Student() {
       super();
       // TODO Auto-generated constructor stub
   }
  
  
   public Student(String stuName, double qualitPts, int credithrs) {
       super();
       this.stuName = stuName;
       this.qualitPts = qualitPts;
       this.credithrs = credithrs;
   }


   public String getStuName() {
       return stuName;
   }
   public void setStuName(String stuName) {
       this.stuName = stuName;
   }
   public double getQualitPts() {
       return qualitPts;
   }
   public void setQualitPts(double qualitPts) {
       this.qualitPts = qualitPts;
   }
   public int getCredithrs() {
       return credithrs;
   }
   public void setCredithrs(int credithrs) {
       this.credithrs = credithrs;
   }
  
   public Course getC() {
       return c;
   }


   public void setC(Course c) {
       this.c = c;
   }
  
   @Override
   public String toString() {
       System.out.println("Student Name: "+stuName);
       System.out.println("Student Quality points: "+qualitPts);
       System.out.println("Student Credit hour: "+credithrs);
       System.out.println("Student course grade points: "+c.pts);
       System.out.println("Student course credit hours: "+c.hrs);
       return super.toString();
   }

  
}

This is Course class:

package com.studentGrade;

public class Course {

   double pts;
   int hrs;
  
   public Course() {
       super();
       // TODO Auto-generated constructor stub
   }
  
  
   public Course(double pts, int hrs) {
       super();
       this.pts = pts;
       this.hrs = hrs;
   }


   public double getPts() {
       return pts;
   }
   public void setPts(double pts) {
       this.pts = pts;
   }
   public int getHrs() {
       return hrs;
   }
   public void setHrs(int hrs) {
       this.hrs = hrs;
   }
  
  
}

This is your Driver class:

package com.studentGrade;

import java.util.Scanner;

public class Assignment5 {
   public static void printMenu(){
       System.out.println(" Choose an Action "
               +"----------------------------- "
               +"A: Add Course Grade "
               +"C:Calculate GPA "
               +"P:Print Student Information "
               +"T:Toatal number of student "
               +"?:Display Menu again "
               +"Q:Quit the program ");
      
   }

   static Student st1;
   static Student st2;
   public static void main(String[] args) {
      
       Scanner console=new Scanner(System.in);
       System.out.println(" Enter name of Student: ");
       String stuName=console.next();
       System.out.println(" Enter Quality points earned: ");
       double qualitPts=console.nextDouble();
       System.out.println(" Enter credit hrs completed: ");
       int credithrs=console.nextInt();
      
       st1=new Student(stuName, qualitPts, credithrs);
       System.out.println("Next Student");
       System.out.println(" Enter name of Student: ");
       String stuName1=console.next();
       System.out.println(" Enter Quality points earned: ");
       double qualitPts1=console.nextDouble();
       System.out.println(" Enter credit hrs completed: ");
       int credithrs1=console.nextInt();
      
       st2=new Student(stuName1, qualitPts1, credithrs1);
       printMenu();
       String choice="";
       do{
       System.out.println(" Please enter a command: ");
       choice=console.next();
       switch(choice){
       case "A":
           double pts=0;
           int hrs=0;
           System.out.println(" Do you want add course for "+st1.getStuName()+" : ");
           if(console.next().toUpperCase().equals("YES")){
           System.out.println(" Enter course grade (0.0 ~ 4.0) for "+st1.getStuName()+" : ");
           pts=console.nextDouble();
          
           System.out.println(" Enter course credit hours for "+st1.getStuName()+" : ");
           hrs=console.nextInt();
           Course c1=new Course(pts, hrs);
           st1.setC(c1);
             
           }
           System.out.println(" Do you want add course for :"+st2.getStuName()+" : ");
           if(console.next().toUpperCase().equals("YES")){
           System.out.println(" Enter course grade (0.0 ~ 4.0) for "+st2.getStuName()+" : ");
           pts=console.nextDouble();
             
           System.out.println(" Enter course credit hours for "+st2.getStuName()+" : ");
           hrs=console.nextInt();
             
           Course c2=new Course(pts, hrs);
           st2.setC(c2);
           }
          
          
           break;
       case "C":System.out.println(" GPA for "+st1.getStuName()+" : "+st1.c.pts);
       System.out.println(" GPA for "+st2.getStuName()+" : "+st2.c.pts);
          
           break;
       case "P":st1.toString();
       st2.toString();
           break;
       case "T":System.out.println("Total number of student: "+2);
           break;
       case "?":printMenu();
           break;
       case "Q":System.out.println("Thank...You");
           System.exit(0);
           break;
       default:System.out.println("Invalid input");
           break;
          
      
       }
       }while(!choice.equals("Q"));
      
   }
  
}

Output:


Enter name of Student:
AAA

Enter Quality points earned:
1.0

Enter credit hrs completed:
1
Next Student

Enter name of Student:
BBB

Enter Quality points earned:
2.0

Enter credit hrs completed:
2

Choose an Action
-----------------------------
A: Add Course Grade
C:Calculate GPA
P:Print Student Information
T:Toatal number of student
?:Display Menu again
Q:Quit the program

Please enter a command:
A

Do you want add course for AAA :
YES

Enter course grade (0.0 ~ 4.0) for AAA :
1.0

Enter course credit hours for AAA :
1

Do you want add course for :BBB :
YES

Enter course grade (0.0 ~ 4.0) for BBB :
2.0

Enter course credit hours for BBB :
2

Please enter a command:
C

GPA for AAA : 1.0

GPA for BBB : 2.0

Please enter a command:
P
Student Name: AAA
Student Quality points: 1.0
Student Credit hour: 1
Student course grade points: 1.0
Student course credit hours: 1
Student Name: BBB
Student Quality points: 2.0
Student Credit hour: 2
Student course grade points: 2.0
Student course credit hours: 2

Please enter a command:
T
Total number of student: 2

Please enter a command:
?

Choose an Action
-----------------------------
A: Add Course Grade
C:Calculate GPA
P:Print Student Information
T:Toatal number of student
?:Display Menu again
Q:Quit the program

Please enter a command:
Q

Thank..You

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