私はエラーを取得しています:悪いオペランドの型「*」
error: bad operand types for binary operator '*'
if ((monthD * dayD).equals("yearD"))
^
first type: String
second type: String
コードのポイントを掛けたときに月と日付が年等しいかどうかを確認することです。
// Month
String monthD;
System.out.print("What is the month? (For example, August would inserted as '08') ");
monthD = userInput.nextLine();
// Day
String dayD;
System.out.print("What is the day? (For example, the 10th of the month is inserted as '10') ");
dayD = userInput.nextLine();
// Year
String yearD;
System.out.print("What is the year? (For example, 1998 is inserted as '98') ");
yearD = userInput.nextLine();
// Is this date magic?
if ((monthD * dayD).equals("yearD"))
{
System.out.print("This date is magic!");
}
else
{
System.out.print("This date is not magic!");
}
あなたはintをしたいときにあなたの入力をなぜ文字列として読むのですか? – Tom
論理が間違っている場合は、最初に比較したいことを確認してください。 – Omore
私はintとdoubleを試してみましたが、うまくいきませんでした。これは私が試した最後のオプションです。他に何をすべきですか? – MadCodez