【发布时间】:2014-11-30 12:40:09
【问题描述】:
我需要读取用户输入的薪水,然后打印员工的姓名和姓氏 (姓氏必须为大写字母)使用文本文件中的数字格式对象的薪水超过指定值。 如果输入的薪水小于100,则打印消息''薪水必须大于100',如果大于文件中的薪水,则打印消息“没有员工有这个薪水。”
文本文件名为employee.text 包含员工的姓名和姓氏,城市, 部门、工资和日期
卡尔约翰逊巴黎生产 900 20/07/2000
Wiley Cyrus 伊斯坦布尔采购 800 21/05/2005
哈利波特伦敦会计 780 30/05/2001
Bruce Wayne Gotham 质量 450 05/08/2007
这是我的代码到目前为止我没有得到输出?
Scanner scanFile = new Scanner(new File("Employee.txt"));
NumberFormat fmt = NumberFormat.getCurrencyInstance(Locale.US);
Scanner scan = new Scanner(System.in);
System.out.println("Enter salary: ");
int salary = scan.nextInt();
if(salary < 100)
System.out.println("The salary must be bigger than 100");
else
if(salary > 900)
{
System.out.println("There is no employee has this salary.");
}
while(scanFile.hasNextInt())
{
int sal = scanFile.nextInt();
String code = scanFile.next();
if(sal >= salary)
System.out.println(code + fmt.format(sal));
}
【问题讨论】:
标签: java javascript