27天7

阅读: 评论:0

27天7

27天7

许多社区都有“雷达”标志,告诉司机他们的速度是多少,希望他们能够慢下来。
你将输出一个“雷达”标志的信息,根据司机驾驶车速的情况向他(她)显示信息。

在此,郑重地提醒各位小伙伴们:在道路上驾驶机动车一定要遵守交通规则,注意交通安全!道路千万条,安全第一条!!!

输入格式:

在一行内输入2个整数。第一个表示速度的限制,第二个表示司机的开车速度。

输出格式:

如果司机没有超速,输出应该是:Congratulations, you are within the speed limit!
如果司机超速行驶,输出为:You are speeding and your fine is F.(F为上表中描述的罚款数额)

输入样例1:

40 39

输出样例1:

Congratulations, you are within the speed limit!

输入样例2:

100 131

输出样例2:

You are speeding and your fine is 500.

输入样例3:

100 120

输出样例3:

You are speeding and your fine is 100.

代码

import java.util.*;
public class Main {public static void main(String[] args) {int x=0,limit=0,s=0;Scanner sc = new Scanner(System.in);//初始化,养成习惯,不然有些编译器运行不了limit = sc.nextInt();x = sc.nextInt();if(limit >= x){System.out.println("Congratulations, you are within the speed limit!");}else{s = x - limit;if (s >= 1 && s <= 20)System.out.println("You are speeding and your fine is 100.");else if(s > 20 && s <= 30)System.out.println("You are speeding and your fine is 270.");else if(s > 30)System.out.println("You are speeding and your fine is 500.");}}
}

本文发布于:2024-02-03 04:31:24,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170690588448661.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

上一篇:超速罚款
标签:
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23