Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Java Lab 2: Control Structures                          Wednesday, June 16, 2004 
 
Read instructions carefully! Following instructions is part of the grade for this lab. 
Please do not hesitate to ask any of the team members for clarifications. 
  
This lab is due at 2pm today, at which point solutions will be posted at a location to be 
announced to the class.  
 
0. Rename the personal folder in your C:\java\ directory to your last name if you have 
not already done so. Please ensure that there are no spaces in the name of the folder.  
Create a new folder named lab2 in this folder (C:\java\lastName). This is the folder to 
which you will be saving all the files required for this lab. 
 
1. (1 point) Using notepad (Menu->Programs->Accessories->notepad), create a new class 
called UsingControlStructures. 
 
2. (2 points) Add a main method to the class and in that method, declare and initialize a 
variable to represent a person's age. 
 
3. (2 points) In the main method, write an if-else construct to print out "You are old 
enough to drive" if the person is old enough to drive and "You are not old enough to 
drive" if the person is too young. 
 
4. (3 points) Also in the main method, write a for loop that prints out all the odd 
numbers from 100 to 0 in decreasing order. 
 
5. (2 points) Do Step 4 with a while loop instead of a for loop.  
 
6. CheckOff 
Please ensure that you have the file UsingControlStructures.java in the folder named 
lab2 that you created in step 0.  
If you are ready to be checked off before 2pm, call one of the team members who will 
assign you a grade for the lab. We will not accept modifications to the required files 
after the lab is officially due.