CSE1020 Labtest 1C

Please read this part carefully

No collaboration is allowed during a labtest. Please refrain from speaking with other students during the test. If you have a question, please ask the teaching assistants or the instructor.

In your home directory you will find a copy of a solution to the ColourConvert problem from Lab 02. You may use pens/pencils and blank sheets of paper. No other aids are allowed.

You may use magic numbers instead of named constants for this test.

Your work will be evaluated based on its correctness and conformance to the style rules. Your code must compile to receive a passing grade.

Remember to save your work and submit your work at regular intervals during the test.

Test Problem

In robotics, a simple method of estimating how far a wheeled robot has travelled is to count the number of revolutions a wheel has turned and multiply by the circumference of the wheel. Your car uses a similar method to record how far it has travelled.

Write a program called Revolution that reads one integer number followed by one real number from the command line. The first number is the number of revolutions made by a wheel. The second number is the radius of the wheel in meters.

You might not know how to read real values from the command line; you can use the following line of code to read the wheel radius from the command line:

double radius = Double.parseDouble(args[1]);

 

Your program should compute the distance travelled by the wheel (given the number of revolutions and its radius) in meters and in kilometers. The circumference of the wheel can be computed as:

2 * Math.PI * radius

The distance travelled in kilometers should be converted to an integer value not exceeding the actual distance travelled (i.e., you need to cast the number of kilometers to int).

Your program should output the distance travelled as being between two integer values in meters, and the integer number of kilometers. For example, if the wheel travels 3.1 meters, then your program should generate output identical to:

Distance travelled is between
3 and 4 meters
or at least 0 kilometers

Here are some more output examples:

java Revolution 50 0.4
Distance travelled is between
125 and 126 meters
or at least 0 kilometers

java Revolution 1000 0.35
Distance travelled is between
2199 and 2200 meters
or at least 2 kilometers

java Revolution 3310 0.6
Distance travelled is between
12478 and 12479 meters
or at least 12 kilometers

 

Submit

Submit your program using the command:

submit 1020 test01C Revolution.java

You may leave when you are finished.