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
If you were setting up a network with 100 nodes and you wanted no more than 25 nodes per segment: what devices and connections w
STatiana [176]

Since at present number user or nodes in an organization counts is 100 and it can be further extended. Moreover concurrent at presented is 25 nodes is active.

<u>Explanation:</u>

So as best practice network administrator has keep in mind and select hardware application.

1. Server with high end rams and further extendable.

2. Minimum life of hardware such as routers, switch or managed or firewall should be considered or two years. But to technology improvement it is possible for 1 year only

3. Upgradable hardware appliances and software updates should be possible with mini cost effect.

4. Network security   and update or upgradable workstation or desktop or laptop to be consideration.

5. Functional operation of an organization should run smoothly.

8 0
2 years ago
Class Main {
Ganezh [65]

Answer:

class Main {

 static void printPowers(int howMany, int nrRows) {

   for(int n=1; n<=nrRows; n++) {

     for(int power = 1; power<=howMany; power++) {

       System.out.printf("%d ", (int) Math.pow(n, power));

     }

     System.out.println();

   }

 }

 public static void main(String[] args) {

   printPowers(3, 5);

 }

}

class Main {

 static void printPowers(int howMany, int nrRows) {

   int n = 1;

   do {

     int power = 1;

     do {

       System.out.printf("%d ", (int) Math.pow(n, power));

       power++;

     } while (power <= howMany);

     System.out.println();

     n++;

   } while (n <= nrRows);

 }

 public static void main(String[] args) {

   printPowers(3, 5);

 }

}

Explanation:

The for loop gives the cleanest, shortest code.

4 0
2 years ago
Software licensed as proprietary
steposvetlana [31]

Answer:

Does not permit source code changes.

Explanation:

3 0
3 years ago
Read 2 more answers
Badin Industries runs a web application that processes e-commerce orders and handles credit card transactions. As such, it is su
Novay_Z [31]

Answer:

The correct option is C.

Explanation:

As Badin Industry is using the Payment Card Industry Data Security Standard (PCI DSS) which required the scan to be be done at least annually if there is no change in the application and when the application is changed.

In this context, provided there is no application change the minimum requirement for the scan is once in the year thus the correct option is C.

7 0
3 years ago
Read 2 more answers
In modern computer memory, each location is normally composed of one byte.
Paraphin [41]
An actual parameter in a method call, or one of the values combined by an operator
4 0
3 years ago
Other questions:
  • In the game of economics, which player has the role of providing goods and services
    10·1 answer
  • Press the _______ key to move to the next cell in a row.
    12·2 answers
  • Put the steps of the decision-making process in the correct order.
    12·1 answer
  • Suppose arraylist list1 is [1, 2, 5] and arraylist list2 is [2, 3, 6]. after list1.addall(list2), list1 is __________.
    8·1 answer
  • True or false? A medical assistant can check for available exam rooms and providers using an electronic scheduling system.
    8·1 answer
  • Which of the following statements about email is true?
    5·1 answer
  • Imagine you are a toy designer. How would you use measuring, dimensions, volume, and surface area information to create your toy
    10·2 answers
  • To have a reason or purpose to do something
    8·2 answers
  • Identify and explain 3 methods of automatically formatting documents​
    8·1 answer
  • Consider the following incomplete method. Method findNext is intended to return the index of the first occurrence of the value v
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!