Write a statement that increases numPeople by 5. Ex: If numPeople is initially 10, the output is: There are 15 people.

import java.util.Scanner;

public class AssigningNumberToVariable {
public static void main (String [] args) {
int numPeople;

numPeople = 10;

/* Your solution goes here */

System.out.print("There are ");
System.out.print(numPeople);
System.out.println(" people.");
}
}

Respuesta :

Answer:

import java.util.Scanner;

public class AssigningNumberToVariable {

public static void main (String [] args) {

int numPeople;

int numPeople_inc;

numPeople = 10;

/* solution */

numPeople_inc=numPeople+5;

System.out.print("There are ");

System.out.print(numPeople_inc);

System.out.println(" people.");

}

}

Explanation:

1. Declare a new variable called: numPeople_inc

2. Add 5 each time: numPeople_inc=numPeople+5;

3. Print the answer:  numPeople_inc=numPeople+5;

Optional, just write the line in the place where says: " your solutions goes here":

numPeople = numPeople+5;