Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java 1. Type a statement that reads a user-entered integer into variable numUsers. Assume scnr already exists. 2. Write a statement that outputs variable numCars

Java

1. Type a statement that reads a user-entered integer into variable numUsers. Assume scnr already exists.

2.

Write a statement that outputs variable numCars as follows. End with a newline.

There are 99 cars. 

Note: Whitespace (blank spaces / blank lines) matters; make sure your whitespace exactly matches the expected output.

public class OutputExample {

public static void main (String [] args) {

int numCars = 99;

Scannerscnr=new Scanner(System.in);

numCars=scnr.nextInt();

System.out.println(numCars);

return;

}

}

3. Type the statements. Then, correct the one syntax error in each statement. Hints: Statements end in semicolons, and string literals use double quotes.

System.out.printl("Predictions are hard."); System.out.print("Especially '); System.out.println("about the future."). System.out.println("Num is: " - userNum); 

import java.util.Scanner;

public class Errors { public static void main(String [] args) { int userNum = 5;

System.out.println ("Predictions are hard. "); System.out.print("Especially '"); System.out.print("about the future."); System.out.println("Num: "- userNum); return; } }

Errors.java:10: operator - cannot be applied to java.lang.String,int System.out.println("Num: "- userNum); ^ 1 error

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

What design features make the blog effective?

Answered: 1 week ago