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
stepan [7]
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.

Computers and Technology
1 answer:
Brilliant_brown [7]3 years ago
4 0

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;

   }

}

You might be interested in
3. (20 points) Write a C++ recursive function that finds the maximum value in an array (or vector) of integers without using any
Luden [163]

Answer:

Following are the code to this question:

In option (i):

#include <iostream>//defining header file

using namespace std;

int findMax(int B[], int x)//defining recursive method findMax

{

if (x == 1)//defining condition when value of n==1

return B[0];//return array first element

return max(B[x-1], findMax(B, x-1)); // calling recursive method inside max method and return value

}

int main() //defining main method  

{

int B[] = {12, 24, 55, 60, 50, 30, 29};//defining array B

int x= 7;//defining integer variable and assign a value

cout << "Maximum element value of the array is: "<<findMax(B, x)<<endl;//calling method findMax and print value

return 0;

}

Output:

Maximum element value of the array is: 60

In option (ii):

\Rightarrow \ T(n) = 1 + T(n-1)\\\Rightarrow  1 + 1 + T(n-2)\\ \Rightarrow  1 + 1 + 1 + ... n \ times \\\Rightarrow  O(n) \\

Explanation:

In the above-given program a recursive method "findMax" is defined, which accepts an array "B" and an integer variable "n" in its parameter, inside the method a conditional statement is used that, checks value of x equal to 1.

  • If the above condition is true it will return the first element of the array and find the max number.
  • Inside the main method, an array B is declared that assigns some values and an integer variable is declared, that also assigns some values, in the last step print method is used that pass value in method and prints its return value.
  • In the option (ii) we calculate the Big-O notation algorithm value.
5 0
4 years ago
_____ represents an entity in the real world that can be distinctly identified.
Margaret [11]

Answer:An object

Explanation: An objects play an important role as the  real world component/entity which display any element which are sourced through their behaviors and different states. Object are the entities that are required in the program for the making the program easier and simpler to understand .

Example- computer can be considered as the object which is related with the  real world.

4 0
3 years ago
Hyperlinks are a part of an HTML element called a(n) _____.
Lyrx [107]

The Anchor element.

HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address. Content within each <a> should indicate the link's destination.

6 0
2 years ago
Read 2 more answers
The columns of a spreadsheet data source are A. form letters. B. the mailing list. C. data points. D. fields.
mojhsa [17]

I believe it is C, I'm so sorry if im incorrect.

8 0
3 years ago
​in older systems, often the user interface mainly consisted of _____ screens that allowed a user to send commands to the system
inessss [21]

Typically, in older systems, the GUI would be Text Based

7 0
3 years ago
Other questions:
  • You have just starting working at Quantum Company. As a new programmer, you have been asked to review and correct various pseudo
    14·1 answer
  • Various units used to measure computer memory
    13·1 answer
  • Which of the following would allow for the QUICKEST restoration of a server into a warm recovery site in a case in which server
    10·1 answer
  • What does it mean to influence the government? Use influence in a sentence.
    8·2 answers
  • Anyone help me please​
    6·2 answers
  • What does the term attenuation mean in data communication?
    11·1 answer
  • What is a benefit of an account with interest?
    5·1 answer
  • What are the 7 c s of communication​
    9·1 answer
  • Data elements in a relational database are organized into ____
    15·1 answer
  • Ann, a user, reports that her pc is running slower than usual. which tool would best allow you to identify the bottleneck?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!