dimanche 28 juin 2015

Why is my java program not calculating? [duplicate]

This question already has an answer here:

I am making a program that finds out your status of part time or full time worker and calculates the commission rate you get based on your sales. Then I just have to print out the status, sales, commisionType, CommissionEarned, and Profit.

I first learned programming on ruby so im trying to figure out if its just indentation or my syntax. Please don't call me a noob because, I know I am...In java at least.

Here is my code:

    import java.util.Scanner;

public class commissionCalculator {

public static void main(String[] args) 
{

    //Variable setting
    Scanner input = new Scanner(System.in);
    String status;
    double sales = 0;
    double parTimeRate = 3.5;
    double fullTimeRateLow = 5;
    double fullTimeRateHigh = 7.5;
    double commissionEarned = 0.0;
    String commisssionType = null;
    double profit;

    //Gathering input from user

    System.out.println("Please enter your status Part-Time (p) or Full-Time (f): ");
    status = input.nextLine();
    status = status.toLowerCase();

    System.out.println("How much did you make in sales?");
    sales = input.nextDouble();

    //Starting of calculations

    if (status == "p" && sales > 0)
    {
        commissionEarned = (sales * parTimeRate) / 100;
        commisssionType = "Rate Applied: 3.5%";
        status = "Part Time";
    }
        if (status == "f" && sales <= 100000.00)
        {
            commissionEarned = (sales * fullTimeRateLow) / 100;
            commisssionType = "Rate Applied: 5%";
            status = "Full Time";

        }
        if (status == "f" && sales >= 10000.00)
        {
        commissionEarned = (sales * fullTimeRateHigh) / 100;
        commisssionType = "Rate Applied: 7.5%";
        status = "Full Time";
        }

    profit = sales - commissionEarned;

    System.out.println(status);
    System.out.println(sales);
    System.out.println(commisssionType);
    System.out.println(commissionEarned);
    System.out.println(profit);
}

}

And my output will see if its full time (f) or part time (p)and the number input but after that is ignoring any calculation. Please help me.

Here is the output: Please enter your status Part-Time (p) or Full-Time (f):

f

How much did you make in sales?

100000

f

100000.0

null

0.0

100000.0

Aucun commentaire:

Enregistrer un commentaire