Question: Write statements that output variable numCars as follows. End with a newline Ex: If numCars is 10, the program should output: Number of cars: 10

Write statements that output variable numCars as follows. End with a newline Ex: If numCars is 10, the program should output: Number of cars: 10 Our system will automatically run your program several times, trying different input values to ensure your program works for any input values 1 import java.util.Scanner; 3 public class VariableOutput f 4 public static void main (String [] args) int numCars; Scanner scnr new Scanner(System.in); numCars scnr.nextInt(O Your solution goes here / 12 System.out.println("Number of cars: "numCars); 15 16 2 Check Try again System.out.print() and System-out println() can be used to output both string literals and a variable's value. Text in double quotes" " is known as a string literal, whereas there are no quotes around the variable's name esting with input Your output 10 Number of cars: 10
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
