本文主要是介绍7-3 汽车超速罚款,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
许多社区都有“雷达”标志,告诉司机他们的速度是多少,希望他们能够慢下来。
你将输出一个“雷达”标志的信息,根据司机驾驶车速的情况向他(她)显示信息。
在此,郑重地提醒各位小伙伴们:在道路上驾驶机动车一定要遵守交通规则,注意交通安全!道路千万条,安全第一条!!!
输入格式:
在一行内输入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.Scanner;public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in);int limitspeed=input.nextInt();int speed=input.nextInt();if(speed<=limitspeed)System.out.println("Congratulations, you are within the speed limit!");else if(speed-limitspeed<=20)System.out.println("You are speeding and your fine is 100.");else if(speed-limitspeed<=30)System.out.println("You are speeding and your fine is 270.");elseSystem.out.println("You are speeding and your fine is 500.");}
}
这篇关于7-3 汽车超速罚款的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!