Computers and Technology

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

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:00, zahraa244
Describe in pseudocode an algorithm that given an integer n and a linked list of elements increases the linked list by a factor of n by replacing each element in the original list with n copies of that element. for example, if l: [18, 7, 4, 24, 11] and n = 3 the resulting list should be l: [18, 18, 18, 7, 7, 7, 4, 4, 4, 24, 24, 24, 11, 11, 11]. if the value of n is less than or equal to 0, the list should be empty after the call. what’s the running time of your algorithm?
Answers: 3
image
Computers and Technology, 22.06.2019 22:20, gingerham1
Avariable of the data type arrays is storing 10 quantities. what is true about these quantities? a. the quantities all have different characteristics. b. the quantities all have the same characteristics. c. five quantities have the same and five have different characteristics. d. it is necessary for all quantities to be integers. e. it is necessary for all quantities to be characters.
Answers: 2
image
Computers and Technology, 24.06.2019 04:30, minecrafter3882
Fall protection, confined space entry procedures, controlled noise levels, and protection from chemical hazards are some of the things that contribute to a safe what
Answers: 1
image
Computers and Technology, 24.06.2019 14:00, youcandoit13
In simple terms, how would you define a protocol?
Answers: 2
Do you know the correct answer?
You have the templates of 2 classes, person and program. the person class has 4 attributes, name, ag...

Questions in other subjects:

Konu
English, 11.05.2021 23:30
Konu
Mathematics, 11.05.2021 23:30
Konu
Mathematics, 11.05.2021 23:30