SpeedPrinter
application is given a speed measured
in mi/hr and "prints" the equivalent speed in km/hr.
The
Text
class contains "functions" that can be used
to convert from a String
to a number.
You must download the Text.class
file to your
working directory for this assignment. (In most browsers, you can do
this by right-clicking on the link above.)
This class has the following two functions:
toNonnegativeDouble()
is passed a String
representation of a non-negative number that may or may not
contain a decimal point, and returns a
double
value (or -1.0 if the String
could not be converted).
toNonnegativeInt()
is passed a String
representation of a non-negative number that must not contain
contain a decimal point, and returns an
int
value (or -1 if the String
could not be converted).
The
System
class (that is part of the standard Java
distribution) gives programmers the ability to "print"
information in the console window.
For example, if you have a double variable named kph
,
the statement:
System.out.println(kph);
will "print" the value of the variable kph
followed
by a new-line character.
The system must satisfy the following physical requirements:
PR-1
The application must be named SpeedPrinter
PR-2
The application must have a double-valued constant named
MILES_PER_KILOMETER
that is assigned the
value 0.621371.
The system must satisfy the following operational requirements:
OR-1
Command-line argument 0 must contain a String
representation of the speed to be converted in mi/hr.
OR-2
The application must "print" [using System.out.println()
]
the equivalent speed in km/hr.
Copyright 2013