subject

Learning Objectives: • understand when to use the different

print statements

• create a variable and assign it a value

• use Scanner to read in user input

• print the value of a variable using

printf

Output:

US state: Texas

Capital: Austin

The capital of Texas is Austin

Description:

Copy and paste the code below:

/

* Name:

* Assignment: A01

/

public class A01{

public static void main(String[] args){

// part1

System. out. print("x x x");

System. out. print("x o x");

System. out. print("x x x");

System. out. println();

// part2

}

}

Write your name in the comment on top. The red letters in the output are the user inputs.

This assignment consists of 2 parts.

First you demonstrate your understanding of the different print statements by modifying a

code segment. Then you read in two Strings and print a statement based on the user input.

Part1:

The code segment provided includes

three print statements that produce

the following output:

Change the code segment so that it

produces the following output:

Hint: you will need to change the number of

statements

Part2:

• Prompt the user to enter a state

• Read in the user response and assign

it to a String variable named state

Hint: before you can assign a value to the

variable state it needs to be declared

• Prompt the user to enter the name of

the capital

• Read in the user response and assign

it to a String variable named capital.

• Use printf and format specifiers to

print the following message:

The capital of state is capital

where you substitute state and capital with

the state and capital entered by the user.

Make your output look exactly like the output displayed above.

Make sure to read in the input next to the prompt but without touching it (use a blank to

separate the prompt from the user input). The output should use a single empty line to

separate the frog displayed in part1 from the output created in part2.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 01:00
Duplicating objects creates copies that a. move differently than the original object b. erase the original object c. look and act like the original object d. add events to a game
Answers: 1
question
Computers and Technology, 22.06.2019 01:50
A.) generate scaffolding to create database for your application. develop all the entities identified in assignment #2. add any additional that may be identified later. b.) add data validation rules to the models that are appropriate for your application and data. c.) create links for each scaffold in the header section. part 2: application updates [30 points] a.) add two additional views to the "home" controller you created in assignment #1. b.) the two views should be named as “privacy" and "". c.) link the two newly created views in the footer section. hint: you would need to modify the “home" controller definition and create “privacy.html.erb" and “.html.erb" files in appropriate locations.
Answers: 3
question
Computers and Technology, 22.06.2019 22:30
Which of the following factors would your hypothetical supervisor look at when deciding whether to test a biological material sample for dna? the amount of other evidence you have implicating a suspect in a crime the annual budget for the crime lab both of the above none of the above; you would almost always order a test
Answers: 3
question
Computers and Technology, 23.06.2019 02:00
Which of the following is not a source of sustainable raw materials? a) coal mine b) flick of sheep c) cotton plantation d) line forest.
Answers: 2
You know the right answer?
Learning Objectives: • understand when to use the different

print statements
Questions
question
Mathematics, 24.04.2020 02:58
question
Mathematics, 24.04.2020 02:58
question
Geography, 24.04.2020 02:58
Questions on the website: 13722361