Java练习题: Demo01 - Demo31

在这里插入图片描述

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

在这里插入图片描述

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));
    }
}

在这里插入图片描述

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);
    }
}

在这里插入图片描述

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

在这里插入图片描述

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

在这里插入图片描述

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 - 2.1 * 44.5) / (3.4 * 0.55 - 50.2 * 2.1));
    }
}

在这里插入图片描述
在这里插入图片描述

public class Demo07{
   
    public static void main(String[] args){
   
        long millis = System.currentTimeMillis();
        long seconds = millis / 1000;
        long minutes = seconds / 60;
        long hours = minutes / 60;
        long currentHours = hours % 24;
        long currentMinutes = minutes % 60;
        long currentSeconds = seconds % 60;
        
        
        System.out.println(currentHours + ":" + currentMinutes + ":" + currentSeconds);
    }
}

在这里插入图片描述

import java.util.Scanner;
public class Demo08{
   
    public static void main(String[] args){
   
        Scanner input = new Scanner(System.in);
        System.out.print("输入一个十进制数:");
        double money = input.nextDouble();
        double penny = money * 100;
        double dollar = penny / 100;
        penny = penny % 100;
        double quarter = penny / 25;
        penny = penny % 25;
        double dime = penny / 10;
        penny = penny % 10;
        double nickle = penny / 5;
        penny = penny % 5;
        int sum = (int)(dollar + quarter + dime + nickle + penny);
        System.out.println("The number of the coin = " + sum);
    }
}

在这里插入图片描述
在这里插入图片描述

import java.util.Scanner;
public class Demo09{
   
    public static void main(String[] args){
   
        Scanner input = new Scanner(System.in);
        System.out.print("Enter a degree in Celsius:");
        double cel = input.nextDouble();
        double fah = cel * 9 / 5 + 32;
        System.out.println(cel + "Celsius is" + fah + "Fahrenheit");
    }
}

在这里插入图片描述

import java.util.Scanner;
public class Demo10{
   
    public static void main(String[] args){
   
        Scanner input = new Scanner(System.in);
        System.out.print("Enter the radius and length of a cylinder:");
        double radius = input.nextDouble();
        double length = input.nextDouble();
        double area = radius * radius * (Math.PI);
        double volume = area * length;
        System.out.println("The area is " + area);
        System.out.println("The volume is " + volume);
    }
}

在这里插入图片描述

import java.util.Scanner;
public class Demo11{
   
    public static void main(String[] args){
   
        Scanner input = new Scanner(System.in);
        System.out.print("Enter a number between 0 and 1000:");
        int num = input.
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值