Starting from:
$35

$29

Lab 4 Solution

Goals




By completing this Lab, students should learn the following:




 
Work with loops (for and while)




Tasks




Create a new package. I suggest naming it Lab4. Use this for the classes you develop in this lab.




Part 1




Write a Java class named Shapes in a file named Shapes.java. Try to use nested loops to create each of the following shapes.




****

****

****

****




*

**

***

****




**

****

******

********




**

****

******

********




********

******

****

**




Some of these involve using some mathematics to print out the asterisks in the correct positions.

Part 2




Determine when tuition at a college will double if it goes up by a simple 7% each year. The current tuition is $10,000.




Perform the calculation in a loop and when the tuition amount exceeds double the original value (20,000) then print the number of years it took to double.










Submission




Attach the modified code to the dropbox for Lab 4.




Steps to export Eclipse Packages:




 
File Export




 
Select General Archive File




 
Select <yourProjectName src Lab4. This will select the files in only the Lab4 package.




 
Browse to a folder where you want to save the zip.




 
Type the name of the zip file as: <yourLastName_<yourFirstName_Lab03.zip




 
Click Finish




In the Lab 4 assignment dropbox, click ‘Browse My Computer’. Locate the zip file you just created and attach it to the Lab assignment.




Click ‘Submit’.

More products