1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lidiya [134]
3 years ago
7

You have the templates of 2 classes, Person and Program. The Person class has 4 attributes, name, age, major and gpa. There is a

constructor for the class that is used to make Person objects. There are setter/mutator methods and getter/accessor methods for those attributes. There is also a printInfo() method that prints out information about the person. The Program class has a main method that has 5 Person objects person1 to person5 declared and initialized. The main method within the class also has a Scanner object that is used to take input for a person number and a newGPA. Your task is as follows:
a. Based on the input of personSelect select the appropriate person and change their GPA to the newGPA input and then print out their information. For instance if the user types in 1 then select person 1 and print out their information using the printInfo method. Do it for all possible inputs from 1 to 5.
b. If however the input is not 1 to 5 then inform the user they have to have to type in an appropriate person number

Person.java

public class Person {
String name;
int age;
double gpa;
String major;
public Person(String aName, int aAge, String aMajor, double aGpa)
{
name = aName;
age = aAge;
gpa = aGpa;
major = aMajor;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String pname) {
name = pname;
}
/**
* @return the age
*/
public int getAge() {
return age;
}
/**
* @param age the age to set
*/
public void setAge(int page) {
age = page;
}
/**
* @return the gpa
*/
public double getGpa() {
return gpa;
}
/**
* @param gpa the gpa to set
*/
public void setGpa(double pgpa) {
gpa = pgpa;
}
/**
* @return the major
*/
public String getMajor() {
return major;
}
/**
* @param major the major to set
*/
public void setMajor(String pmajor) {
major = pmajor;
}
public void printInfo()
{
System.out.println("#########################");
System.out.println("Business College ");
System.out.println("Name: " + name);
System.out.println("Major: " + major);
System.out.println("GPA: " + gpa);
System.out.println("#########################");
}
}
Program.java--------------------------------------------------------------------------------

import java.util.Scanner;
public class Program {
public static void main(String[] args) {
//Declare person objects here
Person person1 = new Person("Dewars",40 , "MIS", 3.9);
Person person2 = new Person("Budweiser",23 , "MIS", 3.2);
Person person3 = new Person("Appletons",25 , "MIS", 3.0);
Person person4 = new Person("Beam",20 , "Finance", 3.7);
Person person5 = new Person("Daniels",19 , "Accounting", 2.9);
Scanner scan = new Scanner(System.in);
System.out.println("Type in a person number whose gpa you would like to change > ");
int personSelect = scan.nextInt();
System.out.println("Type in the gpa you would like the person's to be > ");
double newGPA = scan.nextDouble();
/*
* CODE HERE
*/
}
}
Computers and Technology
1 answer:
Ostrovityanka [42]3 years ago
8 0

Answer:

Hi, I'm going to put the code answer here and you put in the corresponding line to not copy all the code in the answer.

replace the following line or adjust to the following code

/*

* CODE HERE

while(personSelect <= 0 || personSelect  > 5) {

System.out.println("Wrong number, try to input the number in range 1 to 5" );

personSelect = scan.nextInt();

}

if(personSelect == 1){

person1.setGpa(newGPA);

printInfo()

}

else if(personSelect == 2){

person2.setGpa(newGPA);

printInfo()

}

else if(personSelect == 3){

person3.setGpa(newGPA);

printInfo()

}

else if(personSelect == 4){

person4.setGpa(newGPA);

printInfo()

}

else {

person5.setGpa(newGPA);

printInfo()

}

*/

Explanation:

According to the description of code, we have to add some lines to resolve the questions.

a):

In base on the input, we have to modify the <em>attribute GPA</em> with the method <em>setGpa</em> depending on the person chosing. We call the person chosen before and also call the method setGpa( ) and pass  as <em>parameter</em> the GPA value obtained in tha last input

b)

In this case we have to <em>create a loop</em> for iterate the times that is necesary to get a value of person that is permit in <em>range 1 to 5</em>, and hence that we create and individual if condition to assign the GPA to the person chosen.

I hope it's help you.

You might be interested in
Please solve in 5 mins very fast​
Dmitriy789 [7]

Answer:

a. virtual reality

b. Master Boot Records

c. Primary function of a router

d. zoom

Explanation:

4 0
2 years ago
Read 2 more answers
Which group allows you to add notes to your presentation?Ella has finished drafting her presentation. What should she do next?
liq [111]
Ella should view the presentation as a slideshow to see how it will look to her audience. 
6 0
3 years ago
Read 2 more answers
You have important data on your hard drive that is not backed up and your Windows installation is so corrupted you know that you
love history [14]

Answer:

Make every attempt to recover the data

Explanation:

If your decide to format the drive, use system restore or reinstall the windows OS you may end up loosing all your data so the best option is to try as much as you can attempting to recover the data because the data might or definitely will be lost while using other options you think are available.

8 0
2 years ago
Plz hurry !!!
lakkis [162]

Answer: The <u>Ordering Tag List </u>defines the numbering styles of lists in HTML pages.

<ol>

</ol>

Inside this tag, you have <li></li> which will contain individual lists.

For example:

<ol>

   <li> This is my first point. </li>

   <li> This is my second point. </li>

   <li> This is my second point. </li>

</ol>

is displayed as:

1. This is my first point. 

2. This is my second point. 

3. This is my second point.

Read more on Brainly.com - brainly.com/question/9724249#readmore

Explanation:

8 0
3 years ago
Read 2 more answers
Out of a list of the values 2, 45, 18, 22, 8, and 37, what result would the MAX function return?
Vika [28.1K]
37 most likely.
No programming language is specified, and you didn't put what the function is, so assuming it's already implemented, MAX should display the highest number.
8 0
3 years ago
Read 2 more answers
Other questions:
  • A disk rotates at a rate of 7200 revolutions per minute. Seek operations (i.e., moving the access head to a desired track) take
    6·1 answer
  • Describe an application where a parallel circuit might work better than a series circuit
    15·2 answers
  • Your program is going to compare the distinct salaries of two individuals for the last 5 years. If the salary for the two indivi
    15·1 answer
  • How are special characters added to a Word document? Check all that apply.
    11·2 answers
  • Assuming the Direct Hashing function and the Subtraction preprocessing algorithm is used to map keys into indices, give the inde
    15·1 answer
  • Which processor family is most likely found on recent gaming laptops (Gaming laptops require a lot of computational power)?
    11·1 answer
  • What symbol indicates that material has been copyrighted?
    8·2 answers
  • Help plz,l didn’t pay attention in class
    7·1 answer
  • Which of the following statements best reflects the pros and cons of overtime potential for a line installer or repairer?
    15·1 answer
  • mary needs to rename her report.txt file to final_report.txt. which command will allow her to do this?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!