-3
私のコードはswitchステートメントを出力しませんでした別のステートメントまたは条件を使用する必要がありますか? switch文までのすべてのことが完全に機能します。Switch Statmentは出力されません。助けて;
import java.util.Scanner;
public class NewClass {
public static void main (String[]args){
Scanner user= new Scanner(System.in);
int hours;
double biWeekly,payrate,weekly;
String payPeriod;
//Variables
System.out.print("Do you get paid weekly or bi weekly?:");
payPeriod=user.nextLine();
System.out.print("How many hours did you work ths week?:");
hours=user.nextInt();
System.out.print("How much is your pay rate?:");
payrate=user.nextInt();
//the code stops here and wont output the rest
biWeekly=(hours*2)*payrate;
weekly=hours*payrate;
switch(payPeriod){
case "weekly":
System.out.println("Your weekly pay is $"+weekly+" Without tax reductions");
break;
case "biweekly":
System.out.println("Your bi-weekly pay is $"+biWeekly+" without tax reductions");
break;
}
}
}
ステップバイステップデバッグはあなたの友人です。 – sstan
'default'文を追加して、値が – sidgate
であることを確認してください。switch文の前にpayPeriodを印刷したり、payPeriod.trim()を呼び出してみましたか? – Brydenr