【发布时间】:2015-02-13 03:46:55
【问题描述】:
我刚开始学习 Java 编程,在我的第一个项目的最后一部分中收到了这个错误,“税前费用”我一定是弄乱了我的变量,但我不确定。有任何想法吗?
这是我在编译器上收到的错误:
错误:二元运算符的操作数类型错误
第一种类型:双精度
第二种类型:字符串
2 个错误
import java.util.Scanner;
public class project1Naja {
public static void main(String[] args) {
String firstName; // To hold first name
String lastName; // To hold last name
String hours; // Child's hours
final String date; // Date of Service
final double RATE; // Hourly rate
final double TAX_RATE; // Tax percentage
int fee; // Cost before tax added
int taxAmount; // Tax total
double totalFee; // Fee including tax
// Scanner created to read input.
Scanner childCare = new Scanner(System.in);
System.out.print("Enter your first name: " );
firstName = childCare.nextLine();
System.out.print("Enter your last name: " );
lastName = childCare.nextLine();
System.out.print("Enter the child's hours here: " );
hours = childCare.nextLine();
System.out.print("Enter date here: " );
date = childCare.next();
System.out.println("Child Care Service Bill For: " + firstName
+ lastName);
System.out.println("Date of Service: " + date);
System.out.println("Number of hours: " + hours);
System.out.println("Fee before taxes: " = RATE * hours);
}
}
【问题讨论】: