Java はまだ初心者で、ペーパー ボーイ向けの利益計算ツールを作成する任務を負っていますが、次のエラーを受け取りました。
Enter the number of daily papers delivered: 50
Enter the number of Sunday papers delivered: 35
The amount collected for daily papers was: Exception in thread "main" java.util
IllegalFormatConversionException: d != java.lang.Double
at java.util.Formatter$FormatSpecifier.failConversion(Unknown Source)
at java.util.Formatter$FormatSpecifier.printInteger(Unknown Source)
at java.util.Formatter$FormatSpecifier.print(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.io.PrintStream.format(Unknown Source)
at java.io.PrintStream.printf(Unknown Source)
at lab2b_MontelWhite.main(lab2b_MontelWhite.java:24)
これが私がこれまでに持っているものです:
//Paper Boy's Wages Calculator
import java.util.Scanner;
public abstract class lab2b
{
public static void main(String[] args)
{
Scanner input = new Scanner( System.in);
int x;
int y;
int result;
System.out.print("Enter the number of daily papers delivered: ");
x = input.nextInt();
System.out.print("Enter the number of Sunday papers delivered: ");
y = input.nextInt();
double dailyResult = x * .3;
System.out.printf("The amount collected for daily papers was: %d\n",
dailyResult);
int SundayResult = y * 1;
System.out.printf("The amount collected for Sunday papers was: %d\n",
SundayResult);
double totalResult = dailyResult + SundayResult;
System.out.printf("The total amount of money collected was: %d\n",
totalResult);
double ProfitResult = (SundayResult + dailyResult)/2;
System.out.printf("The paper boy's profit is: %d\n", ProfitResult);
}
}
私は何を間違っていますか?ダブルスを追加し、「結果」の名前を変更しました。何が間違っているのかわかりません。