「java语法奖金」java语法基础知识
本篇文章给大家谈谈java语法奖金,以及java语法基础知识对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
- 1、java题 工资的统计要求如下
- 2、用Java编写一个员工类程序:1.属性:员工编号,员工姓名,基本工资,奖金,2.构造方法:至少两个
- 3、java的题目呢,不会,谁能帮我一下吗?就要交了
- 4、java 编程 计算工人工资,
- 5、Java工程师一般月薪是多少?
- 6、java计算工资
java题 工资的统计要求如下
public class Emp {
private static int id;
private static int g;
private static int j;
public static void main(String[] args) {
//定义三个员工的工资总和,局部变量使用要初始化
int sum = 0;
Scanner scan = new Scanner(System.in);
for(int i=0;i3;i++) {
System.out.println("请输入员工编号");
id = scan.nextInt();
System.out.println("请输入员工工资");
g = scan.nextInt();
System.out.println("请输入员工奖金");
j = scan.nextInt();
sum += (g+j);
//输出员工工资总和
System.out.println(g+j);
}
scan.close();
//输入三个员工的总和
System.out.println(sum);
}
}
用Java编写一个员工类程序:1.属性:员工编号,员工姓名,基本工资,奖金,2.构造方法:至少两个
用Java编写一个员工类程序:1.属性:员工编号,员工姓名,基本工资,奖金,2.构造方法:至少两个。如下:
package com.test;
public class Employee {
/**
* 员工编号
*/
private String number;
/**
* 员工姓名
*/
private String name;
/**
* 员工薪水
*/
private double salary;
/**
* 无参数构造函数
*/
public Employee() {
}
/**
* 给属性赋值构造函数
* @param number
* @param name
* @param salary
*/
public Employee(String number, String name, double salary) {
super();
this.number = number;
this.name = name;
this.salary = salary;
}
public static void main(String[] args) {
//员工一,并且构造函数里设置值
Employee e1 = new Employee("e0001", "xiaoming", 5000.0);
System.out.println("员工一:" + e1);
//员工二,用set设置值,get的话可以获取到员工某个属性
Employee e2 = new Employee();
e2.setName("小二");
e2.setNumber("e0002");
e2.setSalary(5500.1);
System.out.println("员工二:" + e2);
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
@Override
public String toString() {
return "Employee [number=" + number + ", name=" + name + ", salary=" +
salary + "]";
}
}
运行结果:
员工一:Employee [number=e0001, name=xiaoming, salary=5000.0]
员工二:Employee [number=e0002, name=小二, salary=5500.1]
java的题目呢,不会,谁能帮我一下吗?就要交了
package com.flo.test.main;
public class Salary {
private final static int curYear = 2013;
public static void main(String[] args) {
Salary s = new Salary();
try {
System.out.println(s.getSal(2012, -2000.34));
} catch (IllegalYearException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalSalaryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private double getSal(int year, double sal) throws IllegalYearException,
IllegalSalaryException {
if (year curYear || year 0) {
throw new IllegalYearException();
}
if (sal 500 || sal 0) {
throw new IllegalSalaryException();
}
int i = curYear - year;
if (i == 0) {
return sal;
}
if (i 3) {
return sal * 1.3d;
}
if (i 5) {
return sal * 1.5d;
}
return sal * 2;
}
class IllegalYearException extends Exception {
/**
* @Fields serialVersionUID : TODO 用一句话描述这个变量表示什么
*/
private static final long serialVersionUID = 1L;
IllegalYearException() {
super("无效入职年份");
}
}
class IllegalSalaryException extends Exception {
/**
* @Fields serialVersionUID : TODO 用一句话描述这个变量表示什么
*/
private static final long serialVersionUID = 1L;
IllegalSalaryException() {
super("无效月工资");
}
}
}
java 编程 计算工人工资,
JAVA计算工人工资,参考例子如下:
import java.util.Scanner;
public class Demo00 {
//定义一个三维数组,用于记录每个部门、分支、绩效工资
private static final float[][][] SALARY_OF_PER_HOUR = {
{{10.75f,12.50f,14.50f},{11.75f,14.50f,17.50f}},
{{13.00f,16.00f,18.50f},{15.00f,18.50f,22.00f}},
{{16.75f,18.50f,20.50f},{19.25f,25.00f,30.00f}}
};
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//输入姓名
System.out.println("请输入姓名:");
String name = sc.nextLine();
//输入部门并验证
System.out.println("请输入部门: A,B,C");
char dept = sc.nextLine().charAt(0);
if(dept'A'||dept'C')
{
System.out.println("输入有误,系统将退出");
System.exit(0);
}
//输入分支机构并验证
System.out.println("请输入分支机构: 1,2");
char div = sc.nextLine().charAt(0);
if(div'1'||div'2')
{
System.out.println("输入有误,系统将退出");
System.exit(0);
}
//输入薪绩表并验证
System.out.println("请输入薪绩表: a,b,c");
char sal = sc.nextLine().charAt(0);
if(sal'a'||sal'c')
{
System.out.println("输入有误,系统将退出");
System.exit(0);
}
//输入小时数
System.out.println("请输入本周工作时间(整小时数):");
int hours = sc.nextInt();
float salary = 0;
//每个小时的薪水
float salaryPerHour = SALARY_OF_PER_HOUR[dept-'A'][div-'1'][sal-'a'];
//分别计算40小时内和超过40小时的薪水
if(hours=40)
{
salary += salaryPerHour*hours;
}
else
{
salary += salaryPerHour*hours+(hours-40)*1.5*salaryPerHour;
}
//输出结果
System.out.println("姓名:\t"+name+"\n部门:\t"+dept+"\n分支机构:\t"+div
+"\n薪绩表:\t"+sal+"\n工作时间:\t"+hours+"\n薪水:\t"+salary);
}
}
//Best wishes!
Java工程师一般月薪是多少?
java工程师月薪具有效数据调查收入为9870元,远远要高于其他行业的月薪水平。
并且java的薪资也并不是属于一程不变的那种,也是会随着工作时间和经验的增加而薪资以及自身的价值也会随之增长。
java计算工资
person类:
public abstract class Person {
public double pay; // 总工资
public int hour; // 课时
public double countPay(int hour) {
return pay;
}
}
助教类:
public class Assistant extends Person {
public final double BASE_PAY = 800; // 基本工资
public final double HOUR_PAY = 25; // 每课时的费用
public double countPay(int hour) {
pay = BASE_PAY + hour * HOUR_PAY;
return pay;
}
}
讲师类:
public class Instructor extends Person {
public final double BASE_PAY = 1000; // 基本工资
public final double HOUR_PAY = 35; // 每课时的费用
public double countPay(int hour) {
pay = BASE_PAY + hour * HOUR_PAY;
return pay;
}
}
副教授类:
public class AssistantProfesson extends Person {
public final double BASE_PAY = 1200; // 基本工资
public final double HOUR_PAY = 40; // 每课时的费用
public double countPay(int hour) {
pay = BASE_PAY + hour * HOUR_PAY;
return pay;
}
}
教授类:
public class Professor extends Person {
public final double BASE_PAY = 1400; // 基本工资
public final double HOUR_PAY = 50; // 每课时的费用
public double countPay(int hour) {
pay = BASE_PAY + hour * HOUR_PAY;
return pay;
}
}
测试类:
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Test {
public static void main(String[] args) {
System.out.println("人员类型如下:");
System.out.println("1 = 助教\r\n2 = 讲师\r\n3 = 副教授\r\n4 = 教授");
System.out.print("请选择:");
BufferedReader personType = new BufferedReader(new InputStreamReader(
System.in));
String type = null;
int hour = 0;
try {
type = personType.readLine();
} catch (Exception e) {
e.printStackTrace();
}
if (type.matches("[1-4]{1}")) {
switch (Integer.valueOf(type)) {
case 1:
hour = getHour();
if(hour == 0){return;}
Person p1 = new Assistant();
double pay1 = p1.countPay(hour);
System.out.println("助教工作" + hour + "课时的工资为:" + pay1);
break;
case 2:
hour = getHour();
if(hour == 0){return;}
Person p2 = new Instructor();
double pay2 = p2.countPay(hour);
System.out.println("讲师工作" + hour + "课时的工资为:" + pay2);
break;
case 3:
hour = getHour();
if(hour == 0){return;}
Person p3 = new AssistantProfesson();
double pay3 = p3.countPay(hour);
System.out.println("副教授工作" + hour + "课时的工资为:" + pay3);
break;
case 4:
hour = getHour();
if(hour == 0){return;}
Person p4 = new Professor();
double pay4 = p4.countPay(hour);
System.out.println("教授工作" + hour + "课时的工资为:" + pay4);
break;
}
} else {
System.out.println("输入数据错误!程序提前推出!");
return;
}
}
public static int getHour() {
System.out.print("请输入工作时间:");
BufferedReader hours = new BufferedReader(new InputStreamReader(
System.in));
String strHour = null;
int hour = 0;
try {
strHour = hours.readLine();
} catch (Exception e) {
e.printStackTrace();
}
if (strHour.matches("^[0-9]+?")) {
hour = Integer.parseInt(strHour);
} else {
System.out.println("输入参数不正确!程序提前推出!");
}
return hour;
}
}
关于java语法奖金和java语法基础知识的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。