Discover a world of knowledge at Westonci.ca, where experts and enthusiasts come together to answer your questions. Connect with professionals on our platform to receive accurate answers to your questions quickly and efficiently. Discover in-depth answers to your questions from a wide network of professionals on our user-friendly Q&A platform.
Sagot :
Answer:
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;
}
}
Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. We're glad you chose Westonci.ca. Revisit us for updated answers from our knowledgeable team.