Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java Programming: Write a program that compares a students IQ to GPA ratio to the average of all the students IQ to GPA ratio. For
Java Programming:
Write a program that compares a students IQ to GPA ratio to the average of all the students IQ to GPA
ratio.
For example: john smith has an IQ of 100 and a GPA of 2.0 and so his ratio is 50. Jim Jones has an IQ of
200 and a GPA of 2.0 and his ratio is 100. The average of the two ratios is 75. In this case, John smith is
below average whereas Jim Jones is above average.
Write a program that compares a student's IQ to GPA ratio to the average of all the students' lQ to GPA ratio For example: john smith has an IQ of 100 and a GPA of 2.0 and so his ratio is 50. Jim Jones has an IQ of 200 and a GPA of 2.0 and his ratio is 100. The average of the two ratios is 75. In this case, John smith is below average whereas Jim Jones is above average Requirements: Define a Ratiolnfo class Three Instance variables and one static variable (All should be private) o GPA (double) o IQ (int) o Percentage (double) //will be assigned to IQ/GPA o totalRatio (static double) //will contain the summation of all percentages One constructor Two arguments (GPA and IQ) Sets GPA and IQ. Make sure the variables passed into the constructor have the same name as the instance variables. From within the constructor, call the calcRatio method (See below) Define an instance method (calcRatio) that calculates the ratio of IQ to GPA and assign it to the percentage instance variable. From inside the calcRatio method, call calcTotalRatio which is a static method (See below). When calling calcTotalRatio from within calcRatio, the current object should be passed into it using the (this) keyword which means that calcTotalRatio will take in an object of type Ratiolnfo. DO NOT pass in percentage, pass the entire object (this) Define a class method (calcTotalRatio, should be static). This method will be called from calcRatio method. Having access to the GPA and IQ of the object, you can update the totalRatio static variable . Defiine an instance method (getStatus) that returns the string good if the person's ratio is above average, bad if below and average if it is the same Getter method to retrieve percentage Define a student class Three Instance variables and one static variable (All should be private) o fname o Iname o ratio (This is of type Ratiolnfone. See below) o numberOfStudents Three constructors No argument (Increment the student count) Two arguments (Iname and fname) Set the Iname and fname. Make sure the variables passed into the constructor have the same name as the instance variables Four arguments (Iname, fname, GPA and Ia) Set the Iname and fname, GPA and IQ. Make sure the variables passed into the constructor have the same name as the instance variables. From within this constructor call the method setRatio (See below) that takes in GPA and IQ in order to assign the ratio variable to an object of type Ratiolnfo You will be creating three student objects using each of the different constructors. Make sure you use the this. and the this(...) syntax to set variables and call other constructors when needed Define a setter method setRatio, that takes two arguments (GPA and IQ) which would allow you to set the ratio instance variable by creating a Ratiolnfo object Define setter methods for both fname and Iname Define a getter method for numberOfStudents You may also want to define a getter method that returns the ratio object for the specific student You can add other method if you needed Define a Driver class Create the three objects. The information for each of these objects will come from user input. First object: Use the no argument constructor, use setter methods for assigning fname and Iname. Also use setter method to assign ratio Second object: Use the two argument constructor. Use the setter method to assign ratio Third object: Use the four argument constructor Display the information for each object (fname, Iname, and ratio. Also display the status for each object to find out if the student fall below, above, or average Here is an optional template that you can use for this group assignment. class Ratiolnfo private int GPA; private int IQ; private double percentage; private static double totalRatio; Ratiolnfo(int GPA, int lQ void calcRatio( double getPercentage) String getStatus( static void calcTotalRatio( Ratiolnfo obj)I class Studentf private String fname,Iname; private Ratiolnfo ratio; private static int studentCount; Studen Student(String fname, String Iname) Student(String fname, String Iname, int GPA, int lQ) void setRatiolint GPA, int lQ void setName(String fname, String Iname) String getName0) Ratiolnfo getRatio)) static int getStudeCou
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started