Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the following code segment such that your implementation of class Student supports the operations used in the main method. Sample runs Input 1: Tim

Complete the following code segment such that your implementation of class Student supports the operations used in the main method. Sample runs Input 1:

Tim CS 30 3.5 3 A 

Output 1:

3.55

Input 2:

James Math 10 4 4 B 

Output 2:

3.71

// TEST

import java.util.Scanner; // your code starts here

// your code ends here public class Test { public static void main(String[] args) { Scanner stdin = new Scanner(System.in);

String name = stdin.nextLine(); String major = stdin.nextLine(); double hours = stdin.nextDouble(); double gpa = stdin.nextDouble();

Student student = new Student(name, major, hours, gpa); double creditHours = stdin.nextDouble(); String grade = stdin.next();

student.addGrade(creditHours, grade);

// print the new GPA System.out.printf("%.2f", student.getGpa());

} }

// STUDENT

package student; // your code starts here

// your code ends here

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions