Answer:
Step-by-step explanation:
The following code was written in Java and modifies the code so that for the given input such as 3 it outputs the exact information shown in the sample output.
import java.util.Scanner;
class CallPersonInfo {
public static void main(String [] args) {
Scanner scnr = new Scanner(System.in);
PersonInfo person1 = new PersonInfo();
int personsKid;
System.out.println("How many kids do you have:");
personsKid = scnr.nextInt();
person1.setNumKids(personsKid);
/* Your solution goes here */
System.out.println("Kids: " + person1.getNumKids());
person1.incNumKids();
System.out.println("New Baby, kids now: " + person1.getNumKids());
}
}
class PersonInfo {
private int numKids;
public void setNumKids(int setPersonsKids) {
numKids = setPersonsKids;
}
public void incNumKids() {
numKids = numKids + 1;
}
public int getNumKids() {
return numKids;
}
}