我有这一点,但有一个错误,我不明白这一点:(。我是比较新的的Java。帮助需要正确的Java代码
package hw;
import java.util.Scanner;
public class Problem1
{
public static void main (String [] args)
{
int cost; int number; double cost_unit; double total;
Scanner entrada = new Scanner(System.in);
System.out.println("Please enter the cost of the product.");
cost = entrada.nextInt();
while (cost>0){
System.out.println("Please enter the amount of units to be sold");
number = entrada.nextInt();
if (number>0);
cost_unit = cost * 1.4;
total = cost_unit*number;
System.out.printf("Cost per unit will be $ %d\n",cost_unit);
System.out.printf("Cost per unit will be $ %d\n",total);
}
}
}
//我只是想用户进入成本的产品,给多家单位订购,我想程序找出产品的最终价格有40%的利润
我建议帖子作者使用像NetBeans这样的IDE ......它会强调`if(number> 0)`并给出警告。 – cdmckay 2009-02-13 23:58:30