$24
Lab Objectives
Be able to create complete Java programs with
Variables, Constants
Primitive data types
Strings
Keyboard input and output
Comments (note: each program should at least have your name, CS140 Lab2 as comments)
Be able to compile and execute a Java program
Be able to test and debug a program and create script file
Task #1 Formatted Output
Write a well-commented program using escape sequences to print out the following: your name, your major, and your study list. The output should look exactly like this: (note: name, major, study list could change but not the format.)
Student: “Tyler Wood”
Major: \Computer Science\
Study List: CS ‘130’, ‘140’, and MAT ‘115’
Task #2 Keyboard Input
Write a well-commented program that will ask the user to enter the following information in the given order:
Name (String)
Age (int)
Company Name (String)
Monthly Salary (double)
Your Program should display a message similar to the following: (note: your program should change the monthly salary entered to annual salary.)
My name is Tyler Wood, my age is 20 and
I hope to work for Google and earn $1000000.0 per year.
Submission requirement:
Submit a script file on blackboard under Lab2. Create a script file, say Lab2.txt as follows:
$script Lab2.txt //note: you may use a different file name, but must be in .txt format.
$cat Prog1.java //note: you could use different names for Prog1.java, Prog2.java
$javac Prog1.java
$java Prog1
$cat Prog2.java
$javac Prog2.java
$java Prog2
$exit
Program formatting requirements
Include comments at the beginning of your source code file that contain your name, the lab assignment number, and the date that you completed the assignment. For example, your comments would look like this:
//Authors: Tyler Wood and Jane Doe
//Assignment: Lab #1
//Completed (or last revision):
Also, may add comments to your source code where appropriate. Details will be practiced in the following assignments.
Please try to follow program convention or style per the document provided to you. Details will be further discussed and practiced in the following lectures and assignments.