1.
package xiangmu1;
import java.util.Scanner;
public class work4 {
public static void main(String[] args) {
float protein=6.4f;
Scanner sc=new Scanner(System.in);
System.out.println("请购买牛奶的盒数:");
int boxnumber=sc.nextInt();
float chiefprotein=protein*boxnumber;
System.out.println(boxnumber+"盒牛奶含有的蛋白质:"+chiefprotein);
sc.close();
// TODO Auto-generated method stub
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/217192e263e11e73067ef1a89b201016.png)
2.
package xiangmu1;
import java.util.Scanner;
public class work3 {
public static void main(String[] args) {
float money=15.5f;
Scanner sc=new Scanner(System.in);
System.out.println("请输入售出汉堡的数量:");
int number=sc.nextInt();
System.out.println("一天总出售的汉堡数量为:"+number+"个");
float totalprice=money*number;
System.out.println("全天总出售的总金额为:"+totalprice+"元");
sc.close();
// TODO Auto-generated method stub
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/0b694b9993b0358e94f5b97a10957e8a.png)
3.
package xiangmu1;
import java.util.Scanner;
public class work5 {
public static void main(String[] args) {
System.out.println("请输入速度");
Scanner sc=new Scanner(System.in);
float speed=3.6f;
int number=sc.nextInt();
System.out.println(number+"km/h="+Math.floor(number/speed)+"m/s");
sc.close();
// TODO Auto-generated method stub
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6f08a02a42fcf682b2f00052b24ca23b.png)
4.
package xiangmu1;
import java.util.Scanner;
public class work6 {
public static void main(String[] args) {
System.out.println("购票信息");
System.out.println("--------------");
System.out.println("目的车站:人民广场");
double ticket=2;
System.out.println("票价:"+ticket);
System.out.println("购票数量");
Scanner sc=new Scanner(System.in);
int num1=sc.nextInt();
System.out.println("购票数量:"+num1);
System.out.println("应付金额:"+(num1*ticket));
int sum=10;
System.out.println("已付金额:"+sum);
System.out.println("找零:"+(sum-(num1*ticket)));
sc.close();
// TODO Auto-generated method stub
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/ffc30974110e56bcc30f3665a1b431b6.png)