1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ludmilkaskok [199]
3 years ago
8

Print person1's kids, call the incNumKids() method, and print again, outputting text as below. End each line with a newline.Samp

le output for below program with input 3:Kids: 3New baby, kids now: 4// ===== Code from file PersonInfo.java =====public class PersonInfo { private int numKids; public void setNumKids(int setPersonsKids) { numKids = setPersonsKids; } public void incNumKids() { numKids = numKids + 1; } public int getNumKids() { return numKids; }}// ===== end =====// ===== Code from file CallPersonInfo.java =====import java.util.Scanner;public class CallPersonInfo { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); PersonInfo person1 = new PersonInfo(); int personsKid; personsKid = scnr.nextInt(); person1.setNumKids(personsKid); /* Your solution goes here */ }}// ===== end =====

Computers and Technology
2 answers:
professor190 [17]3 years ago
8 0

Answer:

System.out.println("Kids: " + person1.getNumKids());

person1.incNumKids();

System.out.println("New baby, kids now: " + person1.getNumKids());

Explanation:

Reminder: To be able to call a function that is inside a class, we need to use an object of that class. In this case, person1 is our object. If we would like to access any function, we need to type person1.functionName().

1) We need to call getNumKids() to get how many kids they have (It is 3 because user inputs 3 and it is set to the this value using setNumKids() function). To call this function, we need to use person1 object that is created earlier in the <em>main</em> function. To be able to print the result, we call the function inside the <em>System.out.println().</em>

2) To increase the number of kids, we need to call incNumKids() method with person1 object again. This way number of kids are increased by one, meaning they have 4 kids now.

3) To get the current number of kids, we need to call getNumKids() function using person1 object. To be able to print the result, we call the function inside the <em>System.out.println().</em>

andriy [413]3 years ago
6 0

Answer:

System.out.println("Kids: " + person1.getNumKids());

person1.incNumKids();

System.out.println("New baby, kids now: " + person1.getNumKids());

Explanation:

You might be interested in
How can you add and remove categories from a previously created chart? A. Click the Format tab. B. Click the Chart Styles button
hoa [83]
<span>Click the Chart Filters button.</span>
7 0
3 years ago
Read 2 more answers
I have to make a online presentation, which program is the best
LiRa [457]
If you want an online presentation, I think you mean by a website.
Best thing you can find is Google Slides.
if you want a program,
LibreOffice is your best bet. It is completely free and it is for Linux, Windows and possibly Mac.
4 0
3 years ago
Read 2 more answers
Difference between sorting and filtering​
Serggg [28]
<h3>Sorting</h3>

The term “sorting” is used to refer to the process of arranging the data in <u>ascending or descending order</u>.

Example: Statistical data collected can be sorted alphabetically or numerically based on the value of the data.

<h3>Filtering</h3>

The process of data filtering involves selecting a <u>smaller part of your data set to view or analyze</u>. This is done by using that subset to view or analyze your data set as a whole.

Example: A complete set of data is kept, but only a portion of that set is used in the calculation, so the whole set is not used.

<em>Hope this helps :)</em>

5 0
1 year ago
Read 2 more answers
I will give Brainliest to the best answer, I need urgent HELP
laila [671]
The answer is B. Range
4 0
3 years ago
Please help with attached file
Paul [167]
Where is the attached file?
8 0
3 years ago
Read 2 more answers
Other questions:
  • Pick 2 different operating systems and discuss how they can be used in daily operations.
    5·1 answer
  • Secops focuses on integrating the need for the development team to provide iterative and rapid improvement to system functionali
    14·1 answer
  • The icon below represents the ____________.
    8·1 answer
  • What is the best kernel synchronization solution on multicore systems when a lock is held for brief periods ?
    14·1 answer
  • Thomas drew a rectangle with an area of 6 square cm what is the greatest possible perimeter of this rectangle
    5·1 answer
  • The space where text and content is entered and positioned for onscreen reading or printing
    8·1 answer
  • Simplify 0.2×0.03055 to 3 decimal places​
    15·2 answers
  • Which is the purpose of adding B-Roll footage to a sequence?
    10·1 answer
  • Which of the following described a global network connecting billions of computers and other
    10·2 answers
  • For quantitative data (e.g. the number of milligrams of a drug) coding your data involves?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!