I am writing a program that allows the user to enter 6 temperature readings, and then either
- return the highest initial values + celcius version
- return to original values + conversion to celsius version.
the code in which the array values are set is given:
System.out.print( "Enter Temperature:\t");
Temp = LocalInput.nextInt();
WeatherSpots[K].CatchCount = Temp;
The error message I get is
java.util.IllegalFormatConversionException: f != java.lang.Integer
at java.util.Formatter$FormatSpecifier.failConversion(Unknown Source)
at java.util.Formatter$FormatSpecifier.printFloat(Unknown Source)
at java.util.Formatter$FormatSpecifier.print(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.lang.String.format(Unknown Source)
at p2list.WeeklyReport(p2list.java:102)
at p2list.main(p2list.java:33)"
I also found the exact phrase that is causing me problems:
String.format("%.2d", (WeatherSpots[K].CatchCount - 32) * 5 / 9)"
I know that an error occurs when mine "%._"does not have qualifier rights, but all my variables and arrays are in int, so d should work
here is the rest of the code:
This is how I installed the 1st array:
private static WeatherLocation[] WeatherSpots = new WeatherLocation[6];"
This is a class that in subsequent arrays uses
public class WeatherLocations extends WeatherLocation {
public String LocationID;
public Integer CatchCount;"
arrays = WeatherSpots.LoccationID/Catchcount"
, catchcount
int K;
for(K = 0 ; K < 6 ; K++){
System.out.print( "Enter Temperature:\t");
Temp = LocalInput.nextInt();
WeatherSpots[K].CatchCount = Temp;
, WeatherSpots[K].catchcount celcius
int K= 0;
for(K = 0 ; K < 6 ; K++){
System.out.println( "" + WeatherSpots[K].LocationID +"\t\t" + WeatherSpots[K].CatchCount + "\t\t" + String.format("%.2f", (WeatherSpots[K].CatchCount - 32) * 5 / 9));
, string.format?