【发布时间】:2014-12-15 14:17:13
【问题描述】:
我需要找到收入最高的公司。
到目前为止,我能够从循环中提取最高总收入,但不知道如何获得与该最高收入相关的公司名称。
while(count
{
System.out.print("Enter Company: ");
companyName = kb.nextLine();
System.out.print("Number of hires: ");
noOfHires = kb.nextInt();
kb.nextLine();
//calculations
totalEarnings = noOfHires * 2500 + 10000;
System.out.println("Total Earnings of company is :" + totalEarnings);
totalEarned = "" + totalEarnings;
if(totalEarnings > large ) //If statement for largest number
{
large = totalEarnings;
}
allTotalEarnings += totalEarnings;
count++;
}
【问题讨论】:
-
只是好奇:你是在添加一个带整数的字符串吗?
totalEarned = "" + totalEarnings;
标签: loops while-loop max highest