Programming in Java I



1. For each of the following Java programming language identifiers, determine which are legal identifiers. (Circle the legal identifiers, fix the illegal identifiers)

• weeklySales ______________________________

• last character ______________________________

• class ______________________________

• MathClass ______________________________

• myfirstinitial ______________________________

• phone# ______________________________

• abcdefghijklmnop ______________________________

• 23jordan ______________________________

• my_code ______________________________

• for fun ______________________________

• Monkeys r’ cool ______________________________

• 90210 ______________________________

• year2004 ______________________________

• LhsPatriots ______________________________

2. Name some attributes (variables) that might be appropriate for each of the following classes:

• TelevisionSets ______________________________

• EmployeePaycheck ______________________________

• MedicalRecords ______________________________

• SportsTeams ______________________________

• People ______________________________

• Radius ______________________________

3. Choose the best data type for each of the following so that no memory storage is wasted.

• Your age ______________________________

• The US national debt ______________________________

• Your shoe size ______________________________

• Your middle initial ______________________________

• Your grade point avg ______________________________

• Your friend’s name ______________________________

Problem:

➢ Using pencil and paper, write a program that declares variables to represent the length and width of a room in feet. Use Room as the class name. Use appropriate variables. Get the needed measurements from the keyboard (user enters in data). Output the data with explanatory text. See sample output below.

The length of the room is __ .

The width of the room is __.

➢ Using JCreator, enter your Room program, compile, and execute. Don’t forget to put comments in your program!! Copy and paste output to source code page; print.

Hand in written program and printed source code!!

Bonus to above problem:

• Compute and output the floor space of the room in square feet (area = length * width). Output appropriate statement.

The floor space is ____ square feet.

[pic][pic]

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download