Trying to figure out a problem

I have been trying to figure out where i went wrong with my code the first IF works normally but when try use a number above 5000 the numbers are off. If the salesAmount would be 15000 then the commission would be 400 + 500 + (15000 - 10000) * 0.12 which would give me 1500 but am getting 1200.

import java.util.*;
public class SalesCommission {
    public static void main(String[] args) {
        calculateCommission();
     
    }
    public static void calculateCommission(){
        System.out.println("Enter Sales Amount: ");
        Scanner scan = new Scanner(System.in);
        double salesAmount = scan.nextDouble();
        double commission = 0;
        double firstFive = 5000*0.08;
        double middleFive = 5000*0.10;
       
        if( salesAmount > 1 || salesAmount < 5000 ){
            commission = salesAmount * 0.08;
        }
        else if (salesAmount >= 5000 || salesAmount < 10000){
            commission = firstFive + (salesAmount - 5000) * 0.10;
        }
        else if (salesAmount >= 10000){
            commission = firstFive + middleFive + (salesAmount - 10000) * 0.12;
            }
        System.out.println("The commission is: " + commission);
    }
}

That doesn’t compile. If you were running something, it wasn’t this.

A bit different but I changed it, Thanks for letting me know

Adding prints to show what’s being done and then comparing what should be done would tell you what and where it goes wrong

Just realized my brain is dead restarted it and fixed the problem, am pretty new thanks for the help though

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.