java未对参数类型 int, double 定义运算符 ^
importjava.util.Scanner;publicclasstest20008{publicstaticvoidmain(String[]args){intmo...
import java.util.Scanner;
public class test20008 {
public static void main(String[] args) {
int money, year;
double interest, rate;
Scanner in=new Scanner(System.in);
money=in.nextInt();
year=in.nextInt();
rate=in.nextDouble();
interest =money*(year^(1+rate)) - money;
System.out.println("interest = "+ (int)(interest*100+0.5)/100.0);
}
} 展开
public class test20008 {
public static void main(String[] args) {
int money, year;
double interest, rate;
Scanner in=new Scanner(System.in);
money=in.nextInt();
year=in.nextInt();
rate=in.nextDouble();
interest =money*(year^(1+rate)) - money;
System.out.println("interest = "+ (int)(interest*100+0.5)/100.0);
}
} 展开
2013-09-25
展开全部
异或是不支持double的,这样你必须把interest, rate都定义为int,如下: int money, year,interest,rate;
Scanner in=new Scanner(System.in);
money=in.nextInt();
year=in.nextInt();
rate=in.nextInt();
interest =money*(year^(1+rate)) - money;
System.out.println("interest = "+ (int)(interest*100+0.5)/100.0);
Scanner in=new Scanner(System.in);
money=in.nextInt();
year=in.nextInt();
rate=in.nextInt();
interest =money*(year^(1+rate)) - money;
System.out.println("interest = "+ (int)(interest*100+0.5)/100.0);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
^运算符应用在int类型上面,无法int和double使用.
interest = money * (year ^ (int)(1 + rate)) - money;这样就对了.
interest = money * (year ^ (int)(1 + rate)) - money;这样就对了.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询