import java.util.Scanner; // imports scanner class to read user input
public class commissionsCalc { //opens class
public static void main(String[] args){// opens main
double commissionsRate;
int basePay = 1000;
int monthlySales = 0;
int counter = 0;
double grossPay = 0;
double commissionsAmt;
int curSale = 0;
Scanner input = new Scanner(System.in);
//System.out.println("Please enter a sale amount or type -1 to finish entering sales and calculate gross pay");
System.out.println("Please enter a sale amount or type -1 to finish entering sales and calculate gross pay");
curSale = input.nextInt();
while (curSale !=-1) {//opens while loop
monthlySales += curSale;
counter++;
System.out.println("Please enter a sale amount or type -1 to finish entering sales and calculate gross pay");
curSale = input.nextInt();
}//closes while loop
if (monthlySales < 5000){//opens if statement
commissionsRate = .06;
}//closes if statement
else if (monthlySales > 5000 && monthlySales <10000) {//opens else if statement
commissionsRate = .08;
}
else if (monthlySales >= 10000) {//opens else if statement
commissionsRate = .10;
我需要計算monthlySales,但我不知道如何將我的循環中的所有當前銷售額相加。當用戶提出銷售時,還需要顯示佣金率。我只是不知道我該怎麼做。我正在使用Jgrasp/java。問題計算器問題
你加入你的curSale您montlySales在電流回路 – Coder
是現在即時通訊不知道我怎麼打印我從所有的數字讓屏幕值 –
可以嗎發佈完整的代碼,以便我可以採取刺探措施? – Coder