To determine the values to be printed in the first column

Assignment Help Operating System
Reference no: EM13943460

Objectives

• Construct and use Objects

• Design the public interface of a class

• Implement methods and test code using conditionals

• Implement methods and test code using loops

• Access instance fields and local variables

Hand-in Requirements

The project directory should include the following files:

• Length.xml (the project file)

• Length.java

• LengthTest.java

Overview

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.

• Implement a loop to allow continuous input.

• Implement a loop to check for valid input.

• Implement a method with a loop to calculate and print conversions from one unit to another.

New Methods for the Length Class
Methods:
In addition to the methods last project, 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.

Testing your Length class:

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.

1. Ask the user to enter a number as a double from the keyboard. Store the response in number1.

2. Ask the user to enter a unit as a String from the keyboard. Store the response in unit1.

3. Use a while loop to ensure that the value of unit1 is valid. This will be done using the validUnit method, i.e., calling Length.validUnit(unit1). While unit1 is not valid, obtain a new value for unit1 from the user.

4. Instantiate a Length object named length1 using the input from above, and print length1 using the toString method. Be sure to use a descriptive label.

5. Invoke length1.printConversionTable() to print out a conversion table.

6. Print the values from calling length1 with the getMeters, getInches, getFeet, getYards, and getMiles methods. Be sure to use descriptive labels.

7. Print the sum of the lengths that have been entered by the user so far. You will need to declare a Length variable before the do-while loop, initialize it to 0 meters, and update the variable in the do-while loop.

Reference no: EM13943460

Questions Cloud

Free convection from the thermocouple : A thermocouple enclosed in a 3.2mm stainless steel sheath (e = 0.6) is inserted horizontally into a duct to measure the air temperature inside. The walls of the duct are at 650o C, and the true air temperature is 560o C. What temperature will be in..
Delaying reduce the projects coefficient of variation : NPC has the opportunity to invest in a project that has a 75% chance of generating $500 per year for 7-years under good conditions or a 25% chance of generating $25 per year for 7-years. Assuming that all cash flows are discounted at 10%, calculate t..
Paper on data over cable service interface specification : You need to prepare a paper on data over cable service interface specification - Must include at least 2 diagram
Marketing practice to create marketing communications : Give examples of how EE would use this research data in marketing practice to create marketing communications.
To determine the values to be printed in the first column : 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
How will your recommendation affect lyle translation : Lyle Shipping, a British company, has chartered out ships at fixed-U.S.-dollar freight rates. How can Lyle use financing to hedge against its exposure? How will your recommendation affect Lyle's translation exposure?
Main categories of information assets : 1. Identify and describe the main categories of information assets that may be at risk and have to be protected.
Evaluating experience performance as a clinical educator : Evaluating experience performance as a clinical educator by reflecting on the experience and referring to current relevant educational literature.
Dividend is expected to grow at a constant rate : Butler Corp paid a dividend today of $3.50 per share. The dividend is expected to grow at a constant rate of 8% per year. If Butler Corp stock is selling for $75.60 per share, the stockholders' expected rate of return is:

Reviews

Write a Review

Operating System Questions & Answers

  Explains memory management requirements

Write a 2-page paper that explains memory management requirements. Write a 2-page paper that explains the differences in memory management between Windows and Linux

  Degree of scope creep

There is a school of thought that discusses that, far from being undesirable, few degree of scope creep may in fact be beneficial for certain types of assignments.

  Question about internet use policies

Internet use policies are often utilized in corporations. Conduct independent research on these and construct an Internet use policy for your company or an organization of your choice.

  What is difference between historic and new bsd release unix

What is major difference between the Historic Unix and the new BSD release of Unix System V in terms of Memory Management?

  Question regarding the linux flavors

Look up the different types of Linux and Unix and type up a 1 page listing them out what benefits do each have and where you found the OS at.

  Part-11 what is the difference between interactive

part-11. what is the difference between interactive processing and real-time processing? 2. suppose a time-sharing

  Risk assessment matrix table

Create a risk assessment matrix table for the purchase and integration of six new web servers for a start-up Internet firm. Include a brief (1-2 page) description of rationale for risk ranking (1 thru 5, or very low to very high) and probability d..

  Questions about on ssl

Provide a table showing the Caesar cipher with a key five, and then provide the result of applying this cipher to the text 'I came I saw I conquered'.

  How many pages are needed to store the entire job

Assume a program has 510 bytes and will be loaded into page frames of 256 bytes each, and the instruction to be used is at byte 377. How many pages are needed to store the entire job

  Website migration project

Evaluate alternatives to the company self-hosting the site and build a Gantt chart using Microsoft Project or equivalent software, showing all tasks associated with implementing the Website.

  Determine largest value for which system is schedulable

Assume that four events need 35,20,10, and x me=sec of CPU time, respectively. Determine the largest value of x for which system is schedulable?

  What multimedia elements to use and how to prioritize them

Some multimedia can be difficult to view on a mobile device due to screen size or bandwidth limitations.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd