求解 我的java代码为啥显示输出那一行有错误?

import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while (sc.hasNext()){
double t = sc.nextInt();
double h = sc.nextInt();
double n = sc.nextInt();
shuai (h, n);
}
}
public static void shuai(double x, double y){
int i;
double q, w;
for (i = 0 ; i < y ; i++){
q = x + x / Math.pow(2, i);
w = y / 2.0;
}
System.out.printf("%.2lf %.2lf\n", q, w);
}
}

printf的参数顺序是 Locale,String,Object 自己看看自己传的类型 明显报错啊追问

Locale,String,Object 是什么意思 ?

追答

这是参数
out.format(l, format, args) ;
System.out.printf(l, format, args);
源码方法是 public PrintStream printf(Locale l, String format, Object ... args) { return format(l, format, args);

追问

您能帮我修改一下我的代码吗?谢谢

追答

是不是报这错 我运行了一下
Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = 'l'

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-04-23
请把C和JAVA区分清楚先
相似回答
大家正在搜