Chapter 2: Problem 18
Write statements that do the following: a) Declare a char variable named letter. b) Assign the letter A to the letter variable. c) Display the contents of the letter variable.
/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none}
Learning Materials
Features
Discover
Chapter 2: Problem 18
Write statements that do the following: a) Declare a char variable named letter. b) Assign the letter A to the letter variable. c) Display the contents of the letter variable.
All the tools & learning materials you need for study success - in one app.
Get started for free
Assume that oneChar is a char variable. Write a statement that stores the first character in the string referenced by the city variable (declared in Checkpoint 2.27 ) in oneChar.
On paper, write a program that will display your name on the first line; your street address on the second line; your city, state, and ZIP code on the third line; and your telephone number on the fourth line. Place a comment with today’s date at the top of the program. Test your program by entering, compiling, and running it.
The following program will not compile because the lines have been mixed up. public stati c void main(String[ ) args) ) / / A crazy nixed up progran public class Columbus i System.out.println("In 1492 Columbus sailed the ocean blue."); < ) When [he lines are properly arranged (lie program should display [he following on [he screen: In 1492 Columbus sailed the ocean blue. Rearrange [he lines in the correct order. Tesi the program by entering it on ihc computer, compiling it, and running it.
Write statements using combined assignment operators to perform the following: a) Add 6 to \(x\) b) Subtract 4 from amount c) Multiply y by 4 d) Divide total by 27 e) Store in \(x\) the remainder of \(x\) divided by 7
Write code that displays an input dialog asking the user to enter his or her age. Convert the input value to an int and store it in an int variable named age.
What do you think about this solution?
We value your feedback to improve our textbook solutions.