The project will be submitted electronically through WebCT. Zip up your entire project directory for submission. (Right click on the project folder, follow the Send To link and select Compressed (zipped) Folder.) Once the compression process is done, you will have a zipped file with the same name as your project folder and an extension of .zip. This zipped file will be uploaded to the WebCT system during project submission. The project directory should include the following files:
In the previous projects, you have written programs that convert between different units of length and manipulate Length objects. In this project, you will use loops for data entry and to print out conversion tables.
Methods:
In addition to the methods from Project 1 and Project 2, you will have these methods:
/* Return true if unit is "meters", "inches", "feet", "yards", or "miles" */
static public boolean validUnit(String unit)/* Print a table showing conversions from the unit of this object to meters */
public void printConversionTable()
The validUnit method will be used to streamline data entry.
The printConversionTable method will be used to print a conversion table from the unit of this object to meters. For example, if this object is 36 inches, a table like the following should be printed.
inches meters 10.0 0.254 20.0 0.508 30.0 0.762 36.0 0.9144 40.0 1.016 50.0 1.27 60.0 1.524 70.0 1.778 80.0 2.032 90.0 2.286 100.0 2.54
Due to rounding errors, your values might be slightly different from the above table.
To determine the values to be printed in the first column, perform the following calculation.
double start = Math.pow(10, Math.floor(Math.log10(myNumber)));
The values in the first column will include 1*start, 2*start, and so on up to 10*start. This will be done using a for loop. In addition, myNumber should appear in the first column in the appropriate row.
When the printConversionTable method is finished, be sure that myNumber is equal to its original value.
Use a do-while loop to allow the user to enter and add up a series of lengths. At the end of each iteration, ask the user if they would like to continue. In this loop do the following.