7-1 sdut-sel-2 汽车超速罚款(选择结构) (10 分)

许多社区都有“雷达”标志,告诉司机他们的速度是多少,希望他们能够慢下来。
你将根据输入的最高限速和司机实际开车速度(单位:km/h),通过计算是否超速的情况,输出一个“雷达”标志的信息。

11.jpg

提示:要输出的信息,建议从题目中复制,确保精确匹配。

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

输入格式:

在一行内输入2个整数。第一个表示最高限速,第二个表示司机的开车速度。(单位:km/h)

输出格式:

如果司机没有超速,输出: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.

代码长度限制

16 KB

时间限制

400 ms

内存限制

64 MB

栈限制

8192 KB

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System .in);
        int limit=sc.nextInt();
        int speed=sc.nextInt();
        int a=speed-limit;
        if(a>=1&&a<=20){
            System.out.println("You are speeding and your fine is 100.");
        }
        else if(a>=21&&a<=30){
            System.out.println("You are speeding and your fine is 270.");
        }
        else if(a>30)
        {
             System.out.println("You are speeding and your fine is 500.");
        }
        else
            System.out.println("Congratulations, you are within the speed limit!");
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值