目录
1.计算牛奶中蛋白质的总量
2.输出肯德基一天售出汉堡的数量及金额
3、将高铁速度km/h转换为m/s
4、地铁购票金额计算
1.计算牛奶中蛋白质的总量
import java.util.Scanner;
public class ZY1 {
public static void main(String[] args) {
System.out.println("请输入购买牛奶的盒数:");
float a=6.4f;
Scanner scanner=new Scanner(System.in);
int b=scanner.nextInt();
System.out.println(b+"袋牛奶含有的蛋白质:"+a*b);
}
}
2.输出肯德基一天售出汉堡的数量及金额
import java.util.Scanner;
public class ZY2 {
public static void main(String[] args) {
System.out.println("请输入售出汉堡的数量");
Scanner scanner=new Scanner(System.in);
float a=15.5f;
System.out.println("每个汉堡金额为"+a);
float b=15.5f;
System.out.println("一天总出售汉堡数量为:");
Scanner scanner1=new Scanner(System.in);
int c=scanner1.nextInt();
System.out.println("全天售出的总金额"+b*c);
}
}
3、将高铁速度km/h转换为m/s
import java.util.Scanner;
public class ZY3 {
public static void main(String[] args) {
System.out.println("请输入速度:");
float a=3.6f;
Scanner scanner=new Scanner(System.in);
float b=scanner.nextInt();
System.out.println(b +"km/h="+Math.floor(b/a) + "m/s" );
}
}
4、地铁购票金额计算
import java.util.Scanner;
public class ZY4 {
public static void main(String[] args) {
System.out.println("购票信息");
System.out.println("-----------");
System.out.println("目的车站:"+ "人民广场");
System.out.println("票价:"+2.00);
int a=2;
System.out.print("购票数量:");
Scanner scanner=new Scanner(System.in);
int b=scanner.nextInt();
System.out.println("应付金额:"+a*b);
System.out.print("已付金额:");
int c=scanner.nextInt();
int d=c-a*b;
System.out.println("已付金额:"+c);
System.out.println("找零:"+d);
}
}
————————————————