我正在做班级的家庭作业。你得计算一下这个月的工资。每次我尝试运行它时,它都会不断地说:我该如何解决这个问题?线程“main”中的异常 java.util.InputMismatchException
在 java.util.Scanner.throwFor (Scanner.java:864)
在 java.util.Scanner.next(Scanner.java:1485)
在 java.util.Scanner.nextInt(Scanner.java:2117)
在java.util.Scanner.nextInt(Scanner.java:2076)
在 D2.main(D2.java:23)
import java.util.Scanner;
public class D2
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int L1Cs = 80;
int L2Cs = 120;
int L3Cs = 160;
int L1Ct = 100;
int L2Ct = 140;
int L3Ct = 180;
int L1Csv = 100;
int L2Csv = 150;
int L3Csv = 200;
int BSalary = 3000;
int Stotal, Ttotal, SVtotal;
System.out.println("Please enter your name");
int name = sc.nextInt();
System.out.println("How many sedans have you sold this month");
int Sedans = sc.nextInt();
System.out.println("How many trucks have you sold this month");
int Trucks = sc.nextInt();
System.out.println("How many SUVs have you sold this month");
int SUVs = sc.nextInt();
if(Sedans <= 10)
{
Stotal = (L1Cs * Sedans);
}
else if (Sedans >= 11 && Sedans <=20)
{
Stotal = (L1Cs*10 +(Sedans - 10) * L2Cs);
}
else
{
Stotal = (L1Cs*10 +L1Cs *10 + (Sedans - 10) * L3Cs);
}
System.out.println("Your comission for the sedans is:" + Stotal);
if(Trucks <= 10)
{
Ttotal = (L1Cs * Trucks);
}
else if (Trucks >= 11 && Trucks <=20)
{
Ttotal = (L1Ct*10 + (Trucks - 10) * L2Ct);
}
else
{
Ttotal = (L1Ct*10 + L2Ct *10 + (Trucks - 10) * L3Ct);
}
守着一只汪
相关分类