0

having a problem with executing this in jGRASP not acceptin user input

class salestax {
 public static void main (String[] args)  {
  try   { 
  double price = Double.valueOf(args[0]).doubleValue();
  double salestax = price * 0.0825;
 System.out.println("Sales tax is " + salestax);
 }
  catch (NumberFormatException e)   {
   System.err.println("Usage: java salestax price" );
	 }
	  catch (ArrayIndexOutOfBoundsException e) {
	   System.err.println("Usage: java salestax price" );
	 }
		  catch (Exception e) { System.err.println(e);
	   }
	 }
	  }
3
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by lbarowski
0

Ehhh... We knows you have problem, but What is the problem doc ?

Double.valueOf(args[0]).doubleValue()

Extracts a double value from the given String object (args[0]). Same can be achieved a bit more easily by just Double.parseDouble(args[0])

Edited by stephen84s: n/a

0

i am unable to enter the price value and the response after running is Usage: java salestax price thanks

0

i am unable to enter the price value and the response after running is Usage: java salestax price thanks

So, it says Usage: java salestax price So on the console you should type: java salestax <price> Ex: java salestax 10 (where 10 is the price)

Edited by stephen84s: n/a

-1

Click "Build" / "Run Arguments" in jGRASP to make the arguments entry field visible.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.