当前位置 博文首页 > chenchw的博客:2021-07-05-exercise

    chenchw的博客:2021-07-05-exercise

    作者:[db:作者] 时间:2021-08-02 21:35

    1.假如还有59天放假,问有多少个星期零多少天?

    
    public class Change{
    
    	public static void main(String[] args){	
        int n = 59;
        int week = 59 / 7;
        int day = 59 % 7;
        System.out.println("一共有" + week + "周");
        
        System.out.println("剩余天数:" + day + "天");
    
    
    	}
    }

    2.定义一个变量保存华氏温度,华氏温度转摄氏度的公式为:5/9*(华氏温度-100),请求出华氏温度对应的摄氏温度。234.6

    
    public class Change{
    
    	public static void main(String[] args){	
        int n = 59;
        int week = 59 / 7;
        int day = 59 % 7;
        System.out.println("一共有" + week + "周");
        
        System.out.println("剩余天数:" + day + "天");
        System.out.println("%%%%%%%%%%%%%%%" );
      
        double temperatureofhuashi = 234.6;
    	double temperature = 5.0 / 9*(temperatureofhuashi-100);//要考虑数学公式和java语言的特性,5--->5.0,
    	// 5/9的话结果是0.在进行后面的运算就都是0了。
    	System.out.println("真正的摄氏度:" + temperature);
    
    	}
    }

    体验编程的乐趣哈?

    cs