1
import java.util.Scanner;
public class 第三次作业 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("请输入购买牛奶的盒数:");
int a = sc.nextInt();
System.out.print(a);
double b = a * 6.4;
System.out.printf("袋牛奶含有的蛋白质: %.1f" , b);
}
}
2
import java.util.Scanner;
public class 第三次作业 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入售出汉堡的数量:");
int a = sc.nextInt();
System.out.println("一天总出售汉堡数量为:" + a);
double b = a * 15.5;
System.out.println("全天售出的总金额:" + b);
}
}
3
import java.util.Scanner;
public class 第三次作业 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入速度:");
int a = sc.nextInt();
double b = a * 1000 / 3600;
System.out.println(a + "km/h" + "=" + b + "m/s");
}
}
4
import java.util.Scanner;
public class 第三次作业 {
public static void main(String[] args) {
System.out.print(" 购票信息\n"
+ "-------------------\n"
+ "目的车站:人民广场\n"
+ "票价:2.00\n"
+ "购票数量:");
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = a * 2;
System.out.println("应付金额:" + b);
System.out.print("已支付金额:");
int c = sc.nextInt();
int d = c - b;
System.out.println("找零:" + d);
}
}