Question: Write code that outputs variable numPants as follows. End with a newline. Ex: If the input is: 4 the output is: There were 4
Write code that outputs variable numPants as follows. End with a newline. Ex: If the input is: 4 the output is: There were 4 pants. 1 import java.util.Scanner; LEAFTE22 3 public class OutputTest { 6 8 9 10 11 12 13 public static void main (String [] args) { int numPants; // Our tests will run your program with input 4, then run again // Your program should work for any input, though. Scanner scnr = new Scanner (System.in); numPants = scnr.nextInt(); System.out.println("There were 7 pants.");
Step by Step Solution
3.36 Rating (152 Votes )
There are 3 Steps involved in it
Step 11 import javautilScanner public class OutputTest public static void ... View full answer
Get step-by-step solutions from verified subject matter experts
