Answered You can hire a professional tutor to get the answer.

QUESTION

Lab Steps Step 1: StudentGPAInfo (20 points) You will create a class to store information about a student's courses and calculate their GPA. Your GPA...

Hi,

I have question concerning a homework problem in CIS 355A. I am coding a program in JAVA that will calculate the student GPA and output the student's name and their GPA. This what I have so far.

import java.util.Scanner;public class StudentGPAInfo{        private String studentName;        private String grade;        private String credits;

        public StudentGPAInfo()//Default Constructor        {            studentName= "Not set";            grade = "Not set";            credits = "Not set";        }                public void setStudentName(String studentName)         {             this. studentName = studentName;        }                        public void addClass(String grade, double credits)         {            //Grade is equal to gradePoints            double points = 0;            double gradePoints;            double GPA;                                    if( grade == "A" || grade == "a")             points = 4.0;            else                if(grade == "B" || grade== "b")                points = 3.0;                else                     if (grade == "C" || grade == "c")                        points = 2.0;                    else                        if (grade == "D" || grade == "d")                            points = 1.0;                        gradePoints= points * credits;            GPA = gradePoints /credits;                    }        public double getGPA()        {            return GPA;        }        public void displayStudent ()    {            System.out.println(studentName + ", your GPA is " + String.format("%.2f", GPA));    }    public static void main(String[] args)     {            StudentGPAInfo student = new StudentGPAInfo();            Scanner sc = new Scanner(System.in);                        // Prompt for student name and set it.            System.out.print("Enter student name:  ");            String studentName = sc.nextLine();            student.setStudentName(studentName);            String another = "y";            do            {                System.out.print("Enter class credits:  ");                double credits = sc.nextDouble();                System.out.print("Enter letter grade:  ");                String grade = sc.next();                student.addClass(grade, credits);                                System.out.print("Another class?  (y/n) ");                another = sc.next();            } while (another.equalsIgnoreCase("Y"));            sc.close();                        // Call student.displayStudent() to show results.            student.displayStudent();    }    }I have also attached the document for the assignment which gives you the instructions of how to format the code for the program.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question