Java for Programmers: Lab 3

Alter the previous Lab to supply the float values for the item price and tax rate as arguments to your program.

To do this, you will need to supply parameters to your application at the command line. These parameters are then available in the String[] args argument to the main method. The first value you specify will be args[0] (The first element... we'll discuss this in detail later) and the second will be args[1]. You can assign these to variables of a String type.

Since the parameters are passed as Strings, you will need to use the Float wrapper class to obtain their values as floats. A Float can be obtainted from a String like this:

Float myNum = new Float("5.5");
float num = myNum.floatValue();