readLine() fejl!
har denne kode....---
import java.io.*;
public class TelephoneBill {
static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
public static void main (String[]args) {
try {
System.out.println("Telephone Bill Calculation");
// constant values
final double standingCharge = 18.00; // 18 pounds/quarter
final double unitCharge = 0.0375; // 3.75 pence/unit
int unitsUsed, pounds, pence;
double totalCharge;
// input number of units used
System.out.print("Enter number of units used: ");
unitsUsed = stdin.readLine();
// calculate charge
totalCharge = standingCharge + unitsUsed * unitCharge;
// convert to punds and pence
pounds = (int) totalCharge;
pence = (int) ( ( totalCharge - pounds ) * 100 );
// output charges
System.out.print(unitsUsed);
System.out.println(" units used");
System.out.print("total bill = ");
System.out.print(pounds + "." + pence);
}
catch(Exception e) {
e.printStackTrace();
}
} // main
}
---
og denne fejl kommer når jeg compiler...
---
C:\Documents and Settings\Carsten Risager\Skrivebord\Programmering\Java\Java\TelephoneBill.java:19: incompatible types
found : java.lang.String
required: int
unitsUsed = stdin.readLine();
^
1 error
Tool completed with exit code 1
---
hvad gør jeg galt? nogen?
//WebPsycho
