1469 - 《C语言程序设计》江宝钏主编-习题4-4-加班费

通过次数

0

提交次数

0

时间限制 : 1 秒 内存限制 : 128 MB

编写一个计算员工收入的程序,公司按照规定工时的工资10元/小时付给每个员工160个工时的薪水,按3倍的工资率付给160个工时以外的工资。

题目输入

输入员工的工时数,1个整数。

题目输出

计算员工的收入

输入/输出样例

输入格式

20

输出格式

200

C语言解答

#include <stdio.h>
int main()
{
	int t,profit;
	scanf("%d",&t);
	if(t<=160)
	{
		profit=10*t;
	}
	if(t>160)
	{
		profit=1600+(t-160)*10*3;
	}
	printf("%d\n",profit);
	return 0;	
}

C++解答

#include<iostream>
using namespace std;
int main()
{
	int t,fee;
	cin>>t;
	if (t<=160) fee=10*t;
	else fee=160*10+(t-160)*30;
	cout<<fee<<endl;
	return 0;
}

Java解答


import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		int man_hour=cin.nextInt();
		Employee employee=new Employee();
		employee.setMan_hour(man_hour);
		System.out.println(employee.ComputeIncome());
	}
}

class Employee{
	int hourly;//时薪
	int man_hour;//工时
	int income;
	public Employee() {
		hourly=10;
		man_hour=0;
		income=0;
	}
	public void setMan_hour(int man_hour) {
		this.man_hour = man_hour;
	}
	public int ComputeIncome(){
		income=0;
		if (man_hour<=160)
		{
			income=man_hour*hourly;
		}
		else{
			income=160*hourly+(man_hour-160)*hourly*3;
		}
		return income;
	}
}