7-1 sdut-sel-2 汽车超速罚款(选择结构)&&7-2 sdut-sel-4 计算工资数

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

分数 10

全屏浏览题目

切换布局

作者 周雪芹

单位 山东理工大学

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

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

输入格式:

在一行内输入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 reader=new Scanner(System.in);
        int a,b;
        a=reader.nextInt();
        b=reader.nextInt();
        if(a>b)
            System.out.printf("Congratulations, you are within the speed limit!\n");
        else
        {
            int c=b-a;
            if(c>=1&&c<=20)
                System.out.printf("You are speeding and your fine is 100.\n");
            else if(c>=21&&c<=30)
                System.out.printf("You are speeding and your fine is 270.\n");
            else
                System.out.printf("You are speeding and your fine is 500.\n");
        }
        reader.close();
    }
}

7-2 sdut-sel-4 计算工资数

分数 10

全屏浏览题目

切换布局

作者 周雪芹

单位 山东理工大学

某公司标准上班时间是120小时,每小时工钱是20元, 如果上班时间超出了120小时,超出部分每小时按2倍工资发放。请编写程序计算员工月工资。

输入格式:

输入一个员工的工作小时数。

输出格式:

输出这个员工的工资数。如果输入的工作小时数<=0,则输出0。

输入样例1:

40

输出样例1:

800

输入样例2:

200

输出样例2:

5600

输入样例3:

-30

输出样例3

0

 

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner reader=new Scanner(System.in);
        int a;
        a=reader.nextInt();
        if(a>120)
            System.out.printf("%d\n",120*20+(a-120)*40);
        else if(a<0)
            System.out.printf("0\n");
        else
            System.out.printf("%d\n",20*a);
        reader.close();
    }
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值