subject

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.
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
*/
}
}

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 02:00, hannahliebl2000
What is the largest decimal number that can be represented by a binary number with 4 place values? (remember, each place in a binary number has a value of a power of 2, starting in the ones place with 20.)
Answers: 3
image
Computers and Technology, 22.06.2019 21:00, mazolethrin9632
Which of these is most responsible for differences between the twentieth century to the twenty-first century?
Answers: 2
image
Computers and Technology, 23.06.2019 01:30, giannav57
How do you set up a slide show to play continuously, advancing through all the slides without requiring your interaction? a. click set up slide show, and then select the loop continuously until ‘esc' and show without narration options. b. click set up slide show, and then select the loop continuously until ‘esc' and use timings, if present options. c. click set up slide show, and then select the show presenter view and use timings, if present options. d. click set up slide show, and then select the show without animation and browsed at a kiosk (full screen) options.
Answers: 3
image
Computers and Technology, 23.06.2019 18:30, erjalinalii
Janice recently received her college degree and is looking for a job. she is worried that since she just finished school, she will be required to repay her perkins and direct subsidized loans immediately. janice pulls out the paperwork she signed and reviews it again for repayment information. after reading all of the information, janice discovers that
Answers: 2
You know the right answer?
You have the templates of 2 classes, person and program. the person class has 4 attributes, name, ag...

Questions in other subjects: