Tuesday 29 October 2013

Help with errors on java

Posted by Саша 08:59, under | No comments


Help with errors on java? Help with errors on java?

I've already posted before, but for some reason all of the program did not show. The program complies but does not run as I hoped. I get either a "java.util.MissingFormatArgumentExceptio... Format specifier '5.2f' and a list of other problems. If it remove the decimal format, It still does not work properly. For every name I enter it is invalid.


import java.io.*;
import java.util.*;

public class Unit6_smithm

{
public static void main(String[] args)
throws FileNotFoundException, IOException
{

String firstName;
String lastName;
double propValue;

double assessPValue;
double assessValue;
double propTaxes;



Scanner inFile = new Scanner(new FileReader("property_values.dat" ));
PrintWriter outFile =new PrintWriter("property_values.out");

firstName = inFile.next();
lastName = inFile.next();

outFile.println("Enter First and Last Name: "
+ firstName + " " + lastName);

propValue = inFile.nextDouble();
outFile.printf("Enter your property value: "
+ propValue);

assessPValue = propValue * .92;

outFile.printf("Your Assessed Property Value is %5.2f %5.2f %5.2f "
+ "%5.2f %5.2f %n", assessPValue);

assessValue = (assessPValue) / 1000.0;

propTaxes = assessValue * 9.35;

outFile.printf("Averages test score: %5.2f %n", propTaxes);

inFile.close();
outFile.close();
}
}














0 коммент.:

Post a Comment