Debug_Simple


Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem type

題目說明

  1. 請針對以下程式碼進行除錯
  2. 補上華氏(F)轉攝氏(C)公式:C=(F-32)x5÷9
  3. 使用已宣告的變數(weather和C)顯示正確的結果

vvv請debug以下程式碼vvv

public class Test_0926 {
    public static void main(String[] args) {
        int weather="sunny";
        int F=95.0;//華氏
        int C=;//華氏轉攝氏公式:C=(F-32)x5÷9

        System.out.println("Today is a day.The temperature is.");//請依照題目要求輸出正確的內容

    }
}

輸入

本題無輸入

輸出

Today is a sunny day.
The temperature is 35.

範例輸出 #1

Today is a sunny day.
The temperature is 35.

Comments


  • 0
    scu11156257  commented on Nov. 28, 2024, 3:07 p.m.

    import java.util.Scanner; public class debug程式碼 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
                Scanner in=new Scanner(System.in);
                String weather="sunny";
                int F=(int) 95.0;//華氏
                int C=(int) ((F-32)*5/9);//華氏轉攝氏公式:C=(F-32)x5÷9
                System.out.println("Today is a "+weather+ " day. \nThe temperature is "+C+ ".");//請依照題目要求輸出正確的內容
    
            }
        }

  • 0
    scu11156257  commented on Nov. 28, 2024, 3:00 p.m.

    import java.util.Scanner; public class debug程式碼 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
                Scanner in=new Scanner(System.in);
                String weather="sunny";
                double F=95.0;//華氏
                int C=(int) ((F-32)*5/9);//華氏轉攝氏公式:C=(F-32)x5÷9
                System.out.println("Today is a "+weather+ " day.The temperature is "+C+ ".");//請依照題目要求輸出正確的內容
    
            }
        }