standard output

hey y'all i need help with the following program that calculates property tax at 92% or $1.05 for every $100..

import java.io.*;

import java.util.*;

publicclass PropertyTax

{

publicstaticvoid main (String[] args)

throws FileNotFoundException

{

PrintWriter outFile =new PrintWriter("tax.txt");

String assValueString ="";

System.out.print("Enter Assessed Value: ");

double assValue = Double.parseDouble(assValueString);

double taxableamount = (assValue * .92);

double propertytax = (assValue - taxableamount);

outFile.printf("Assessed Value: " +"$" + assValue);

outFile.printf("Taxable Amount: " +"$" + taxableamount);

outFile.printf("Tax Rate for Each $100.00: " +"$" +"1.05");

outFile.printf("Property Tax:" +"$" + propertytax);

outFile.close();

}

}

i keep getting the error message:

NumberFormatException:

empty String (in sun.misc.FloatingDecimal)

any help would be greatly appreciated =]

Message was edited by:

nsfour

[1897 byte] By [nsfoura] at [2007-11-27 2:55:24]
# 1

String assValueString = "";

System.out.print("Enter Assessed Value: ");

// Looks like you forgot to read assValueString value (user input) here...

double assValue = Double.parseDouble(assValueString);

TimTheEnchantora at 2007-7-12 3:32:07 > top of Java-index,Java Essentials,Java Programming...
# 2
yeah that was my main problem: i completely forgot how to store user input [without a dialog box] into a single variable.. such a simple thingugh, hate to ask you again.. but what should i put there
nsfoura at 2007-7-12 3:32:08 > top of Java-index,Java Essentials,Java Programming...
# 3
System.in?
big_rota at 2007-7-12 3:32:08 > top of Java-index,Java Essentials,Java Programming...
# 4

> yeah that was my main problem: i completely forgot

> how to store user input [without a dialog box] into a

> single variable.. such a simple thing

>

> ugh, hate to ask you again.. but what should i put

> there

From standard input I guess. So depending on your java version:

< 5 : use a [url=http://java.sun.com/j2se/1.4.2/docs/api/java/io/BufferedReader.html]BufferedReader[/url] (that wraps an InputStreamReader for System.in), and its readLine method

>= 5 : use a [url=http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html]Scanner[/url] (which allows reading a double directly, btw)

TimTheEnchantora at 2007-7-12 3:32:08 > top of Java-index,Java Essentials,Java Programming...
# 5
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));String line = reader.readLine();
java_2006a at 2007-7-12 3:32:08 > top of Java-index,Java Essentials,Java Programming...
# 6

okay so i used system.in, however, i've hit another snag..

Scanner console = new Scanner(System.in);

System.out.println("Enter Assessed Value:");

String assValue = console.next();

double taxableamount = (assValue * .92);

double propertytax = (assValue - taxableamount);

i get the error: operator * cannot be applied to java.lang.String,double

how can i multiply assValue by 92%?

nsfoura at 2007-7-12 3:32:08 > top of Java-index,Java Essentials,Java Programming...
# 7
>String assValue = console.next();double assValue = console.nextDouble();or int assValue = console.nextInt();
java_2006a at 2007-7-12 3:32:08 > top of Java-index,Java Essentials,Java Programming...
# 8
thanks 2006 and others
nsfoura at 2007-7-12 3:32:08 > top of Java-index,Java Essentials,Java Programming...