帮忙给看一下错误在哪里,该怎么改正.classMysecondApp {public static void main(String ar[] ) {charc='a';int i=10;float f=15.7;sum(i,f) ;System.out.println("c="+c);}static voidsum(int i,j) {float p;p =i+j;System.out.println("sum is :"+p);
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/17 17:26:34
帮忙给看一下错误在哪里,该怎么改正.classMysecondApp {public static void main(String ar[] ) {charc='a';int i=10;float f=15.7;sum(i,f) ;System.out.println("c="+c);}static voidsum(int i,j) {float p;p =i+j;System.out.println("sum is :"+p);
帮忙给看一下错误在哪里,该怎么改正.
classMysecondApp {
public static void main(String ar[] ) {
charc='a';
int i=10;
float f=15.7;
sum(i,f) ;
System.out.println("c="+c);
}
static voidsum(int i,j) {
float p;
p =i+j;
System.out.println("sum is :"+p);
}
}
帮忙给看一下错误在哪里,该怎么改正.classMysecondApp {public static void main(String ar[] ) {charc='a';int i=10;float f=15.7;sum(i,f) ;System.out.println("c="+c);}static voidsum(int i,j) {float p;p =i+j;System.out.println("sum is :"+p);
class MysecondApp {
public static void main(String ar[]) {
char c = 'a';
int i = 10;
float f = 15.7f;
MysecondApp.sum(i, f);
System.out.println("c=" + c);
}
public static void sum(int i, float j) {
float p;
p = i + j;
System.out.println("sum is :" + p);
}
}
已经全部改完成了.
你想要的是 System.out.println("c=" + (int) c);
上面的那个结果是
sum is :25.7
c=a
加上强转int 之后结果是:
sum is :25.7
c=97