Why did this result fall short of expectations

dongchao_123 注册会员
2023-02-26 18:18

I meant it was supposed to be picture recognition and then gpt said it was supposed to be misidentifying your code

dodo266q 注册会员
2023-02-26 18:18

Part of this answer references GPT, GPT_Pro to better solve the problem
The problem in this question arises in the conversion formula in the code. The formula for converting Celsius to Fahrenheit is: °F =(°C × 9/5) + 32. In your code, you wrote 9321 instead of 9/5, which obviously does not meet the requirements, so the output is 68. To fix this problem, simply change 9321 to 9/5, and the modified code looks like this:

import java.util.Scanner;
public class Changef {
    public static void main(String args[]){ 
        System.out.println("请输入摄氏温度 ");
        Scanner reader=new Scanner(System.in);
        double m =reader.nextDouble();
        double n = m * 9/5 + 32;
        System.out.println("华氏温度为:"+n) ;

Once you've made your changes, enter 20 degrees Celsius and you'll normally get 68 degrees Fahrenheit.

The above is the answer to this question. In summary, when writing code, we should pay attention to the correctness of formula calculation, logical correctness and grammatical correctness to avoid bugs or unnecessary errors.
If the answer is helpful, please accept it.

du_bc1984 注册会员
2023-02-26 18:18
< div class = "md_content_show e397 data - v - 3967" = "" >

there is something wrong with the image recognition, at least, look at yourself

diamondsuper 注册会员
2023-02-26 18:18

ddpaopaovip 注册会员
2023-02-26 18:18

I run your code and the result is


So the code should be fine, recompile and try

in execution