Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Operating System Expert

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.

Operating System, Computer Science

  • Category:- Operating System
  • Reference No.:- M91614326
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Operating System

Question students working at individual pcs in a computer

Question : Students working at individual PC's in a computer laboratory send their files to be printed by a server that spools the files on its hard disk. Under what conditions may a deadlock occur if the disk space for ...

Question description of lasa in this assignment you will

Question: Description of LASA: In this assignment, you will select a real-world operating system (can be for a PC, server, tablet, handheld, or embedded device). You will introduce the operating system and its components ...

Catalog course descriptionin this course students carry out

Catalog Course Description In this course students carry out independent research in a significant technical area of information, network, and computer security. The student is to investigate a technical area, research i ...

State the required answer precisely and then provide proper

State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. Briefly describe the following concepts and indicate how they are related in the context ...

Taskyour job in this assignment is to create two virtual

Task Your job in this assignment is to create two Virtual machines each running a different but the latest distribution of Linux e.g. Ubuntu Server and CentOS. Each of these VM's is to offer services to a user base. The ...

Research types of operating systems that are currently

Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Explain why you think the choice you made ...

Question research hex editors available for mac os and

Question : Research hex editors available for Mac OS and Linux. Based on the documentation, how easy would validating these tools be? Select at least two hex editors for each OS, and discuss what you would do to validate ...

Question what do you see as the major differences between

Question : What do you see as the major differences between UNIX/Linux and other operating systems, such as Windows and Mac OS X? The response must be typed, single spaced, must be in times new roman font (size 12) and m ...

Question note apa format 250 words and three reference

Question: Note: APA format 250 words and three reference without plagarism Computerized Operating Systems (OS) are almost everywhere. We encounter them when we use out laptop or desktop computer. We use them when we use ...

Question topic computerized operating systems os are almost

Question: Topic: Computerized Operating Systems (OS) are almost everywhere. We encounter them when we use out laptop or desktop computer. We use them when we use our phone or tablet. Find articles that describes the diff ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As