Question
Java An Adult object has exactly 3 instance variables used to store the adults first name, last name, and age. There are 3 getter methods,
Java
An Adult object has exactly 3 instance variables used to store the adults first name, last name, and age. There are 3 getter methods, and no setter methods. The initials method returns the adults initials (i.e., the first letter of each name). The method fudgedAge returns an integer which is plus or minus 5 years of the adults age. Do not change the age. For example, if the age is 60, fudgedAge will return a random integer in the range [55,65]. Also include a toString method. No other methods are allowed.
Tester is shown below
public class Tester { public static void main(String[] args) { Adult a = new Adule("Donald", "Trump", 72); System.out.println(a.getFirst()); System.out.println(a.getLast()); System.out.println(a.getAge()); System.out.println(); System.out.println(a); System.out.println(); System.out.println(a.fudgedAge()); System.out.println(a.fudgedAge()); System.out.println(a.getAge()); System.out.println(); System.out.println("Initials: " + a.initials()); } }
Write the code that would be stored in Adult.java. Sample output is shown below.
WIUS. SUIDUP INIC > run Tester Donald Trump 72 Donald Trump Age: 72 Initials: DT > run Tester Donald Trump 72 Donald Trump Age: 72 75 Initials: DTStep 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