Demo01-Demo031

Demo01

public class Demo01{
    public static void main(String[] args){
      System.out.println((9.5 * 4.5 - 2.5 * 3) / (45.5 - 3.5));
  }
}

基础表达输出语句

Demo02

public class Demo02{
    public static void main(String[] args){
        System.out.println(4 * ( 1.0 - (1.0/3) + (1.0/5) - (1.0/7) + (1.0/9) - (1.0/11) ));
        System.out.println(4 * (1.0 - (1.0/3) + (1.0/5) -(1.0/7) + (1.0/9) - (1.0/11) + (1.0/13))); 
    }
}

Demo03

 

public class Demo03{
    public static void main(String[] args){
        System.out.println("周长 = " + 2 * 5.5 * 3.14);
        System.out.println("面积 = " + 5.5 * 5.5 * 3.14);
    }
}

通过公式算面积和周长

 

Demo04

 

public class Demo04 {
    public static void main(String[] args) {
        System.out.println(14 / 1.6 / (45 * 60 + 30) * 60 * 60);
    }
}

 

Demo05

 

public class Demo05{
    public static void main(String[] args){
        System.out.println(14/1.6/(60*60+45*60+35)*60*60 + "公里/小时");
    }
}

 

Demo06

 

public class Demo06 {
public static void main(String[] args) {
    System.out.println("x=" + (44.5 * 0.55 - 50.2 * 5.9) / (3.4 * 0.55 - 50.2 *2.1));
    System.out.println("y=" + (3.4 * 5.9 - 44.5 * 2.1) / (3.4 * 0.55 - 50.2 *2.1));
    }
}

 

Demo07

 

public class Demo07{
    public static void main(String[]args){
        long totalMlliseconds = System.currentTimeMillis();
        System.out.println(totalMlliseconds);//当前总毫秒数
        long totalsSeconds = totalMlliseconds / 1000 ;//总秒数
        long Seconds = totalsSeconds % 60 ;//当前的秒数
        long totalsMinutes = totalsSeconds / 60 ;//总分钟数
        long Minutes = totalsMinutes % 60 ;//当前的分钟数
        long totalHours = totalsMinutes / 60 ;//总小时数
        long Hours = totalHours % 24 ;//当前的小时数
        System.out.println(Hours +":"+ Minutes+":" + Seconds);
    }
}

 

通过换算数据建立变量进行输出,了解格林威治时间和时间的转换关系

Demo08

 

public class Demo08{
    public static void main(String[] args){
        int money = 1156;
        int b = money / 100 ;
        System.out.println(b + "个美元");
        money = money % 100;
        b = money / 25;
        System.out.println(b + "个2分5角");
        money = money % 10;
        b = money / 10;
        System.out.println(b + "个5美分");
        money = money % 5;
        b = money / 1;
        System.out.println(b + "个美分");
         
    }
}

 

Demo09

 

import java.util.Scanner;
public class Demo09{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter a degree in Celsius:");
        double Celsius = scanner.nextDouble();
        
        //将摄氏温度转换为华氏温度
        double Fahrenheit = ((9.0 / 5) * Celsius) + 32;
        
        //输出数据
        System.out.println(Celsius + " Celsius is " + Fahrenheit + " Fahrenheit "); 
    }
}

 

Demo10

 

import java.util.Scanner;
public class Demo10 {
    public static void main (String[] args){
        Scanner in = new Scanner(System.in);
        System.out.print("Enter the radius and lenght of a cylinder:");
        double r = in.nextDouble();
        double l = in.nextDouble();
		
        //计算圆柱体的体积
        do
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值