luanpaixie262
luanpaixie262
采纳率54.8%
2016-03-07 12:02 阅读 1.5k
已采纳

请问这个代码应该如何写,完全没有思路啊,求解

这个怎么写代码啊,一点思路都没有,怎么办啊,求解⋯⋯⋯⋯⋯⋯⋯⋯图片说明

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    luochoudan 丑旦 2016-03-07 13:45

    借鉴一下,改改。
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Runtime runtime = Runtime.getRuntime();
    System.out.println("占用内存:"
    + (runtime.totalMemory() - runtime.freeMemory()));
    long timeStamp = System.currentTimeMillis();
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNextInt()) {
    int tem = scanner.nextInt();
    System.out.println("输入的华氏温度是:" + tem);
    Integer temperature = (tem - 32) * 5 / 9;
    System.out.println("输出的摄氏温度是:" + temperature);
    System.out.println("消耗时间(包含输入):"
    + (System.currentTimeMillis() - timeStamp) + "毫秒");
    }
    scanner.close();
    }

    点赞 评论 复制链接分享
  • Hello_____Word 家吗家吗地 2016-03-07 13:20

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;

    public class Test {
    private static int F;
    public static void main(String[] args) {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            F = Integer.parseInt(br.readLine());
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }   
        System.out.println((int)((F-32)*5/9));
    }
    

    }

    点赞 评论 复制链接分享

相关推荐