$35
COSC 236
Lab 2*
1. Write a complete Java program that produces the following output (use System.out.println() to print each line to the screen):
What is the difference between
a ' and a "? Or between a " and a \"?
One is what we see when we're typing our program.
The other is what appears on the "console."
2. Write a complete Java program that produces the following output (use System.out.println() to print each line to the screen):
A "quoted" String is
'much' better if you learn
the rules of "escape sequences."
Also, "" represents an empty String.
Don't forget: use \" instead of " !
'' is not the same as "
3. Write a program that stores the integers 62 and 99 in variables, and stores their sum in a variable called total. Print out the total to the screen.
4. Write a program that declares the following:
· a String variable named name
· an int variable named age
· a double variable named annualPay
Store your age, name, and desired annual income as literals in these variables. The program should display these values on the screen in a manner similar to the following:
My name is Joe Smith, my age is 26 and
I hope to earn $100000.0 per year.
5. Write a program that has the following String variables: firstName, middleName, and lastName. Initialize these with your first, middle, and last names. The program should also have the following char variables: firstInitial, middleInitial, and lastInitital. Store your first, middle, and last initials in these variables. The program should display the contents of these variables on the screen.
* Questions modified from: Starting Out with Java: From Control Structures through Data Structures. Second Edition, by Tony Gaddis and Godfrey Muganda.
Deliverables:
Submit the .java files through Black Board.