【发布时间】:2015-11-05 19:37:24
【问题描述】:
import javax.swing.JOptionPane;
import java.util.Scanner;
public class pay{
static Scanner sc;
public static void main (String[]args)
{
double Regpay = 8;
double OThour = Regpay * 1.5;
double hours = 0;
double gpay = Regpay * hours;
double Totalpay = OThour + gpay;
Scanner input = new Scanner(System.in);
System.out.println("Normal pay for hours worked less than 40hrs will be, £8.00 per hour");
System.out.println("If workers work more than 40hrs, their pay will be time and a half");
System.out.println("please enter your name");
String name = sc.nextLine();
System.out.println("How many hours did you work this month");
hours = sc.nextDouble();
System.out.println("How many hours overtime did you work");
OThour = sc.nextDouble();
if (hours<=40){
Totalpay = gpay;
System.out.print("You are not entitled to overtime pay");
}else{
if (hours>=41)
Totalpay = gpay + OThour >=1;
}
}
}
我在Totalpay = gpay + OThour >=1; 线上收到错误,我不知道该怎么办,我一直在尝试改变,但我一直收到同样的错误!!!!
【问题讨论】:
-
你想用那条线完成什么?您似乎正在比较
gpay + OThour以查看它是否大于或等于1。 -
gpay + OThour >= 1检查gpay + OThour是否大于或等于 1 并返回true或false,不能将其添加到double,因为它不是号码。