26.2k views
0 votes
Write code that outputs numBaths as follows. End with a new line. Ex: if the input is 3 the output is Baths: 3. Java please!

1 Answer

2 votes

Answer:

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner scnr = new Scanner(System.in);

int numBaths = scnr.nextInt();

System.out.println("Baths: " + numBaths);

}

}

Step-by-step explanation:

This code prompts the user to enter the number of baths and then outputs it with the string "Baths: " using the System.out.println() method.

User Parth Bhoiwala
by
7.5k points