本文介绍了如何使用java增加2%,5%等工资的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何构建一个程序

将要求用户输入他们的工资和你的程序可以

计算工资增量

将根据下表获得。

使用if ---- else选择控制语句。



工资增量



N 800 - N1000 2%



N 101 - N2000 5%



N 201 - N4000 8%



N 400> 10%

我试过这段代码,但我想知道我们是否正确。谢谢



How to construct a program
that will require the user to input
their salary and your program can
calculate the increment in salary that
will obtain based on the table below.
Using if----else selection control statement.

Salary Increment

N 800 - N1000 2%

N 101 - N2000 5%

N 201 - N4000 8%

N 400> 10%
i have tried this code but i wants to know weither i am correct or not. Thanks

import java.util.Scanner;
public class Question2
{
 public static void main(String [] args)throws IOException
 {
  float salary;
  double increment;
 Scanner scanner = new Scanner(new InputStreamReader(System.in));


  System.out.print("Enter Your Salary:");

  salary = scanner.nextFloat();

  if ((salary >=800) && (salary <=1000))

  {
   increment=(2 / salary)*100;
   System.out.println("\nPercentage increment is: " + increment + "\n");
  }
  else if ((salary >=101) && (salary <=2000))
  {
   increment=(5 / salary)*100;
   System.out.println("\nPercentage increment is: " + increment + "\n");
  }
  else if ((salary >=201) && (salary <=4000))
  {
   increment=(8 / salary)*100;
   System.out.println("\nPercentage increment is: " + increment + "\n");
  }
  else if (salary > 400 )
  {
   increment=(10 / salary)*100;
   System.out.println("\nPercentage increment is: " + increment + "\n");
  }
  else
  System.out.println("\nNo More Increment For This Salary\n");

    }
}

推荐答案


这篇关于如何使用java增加2%,5%等工资的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 00:23