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