I have created the following code and I want it to ask for a Sales amount to be entered by the user then multiply that by the commission and add it to the salary to list a compensation.
However all my attempts leave me where I need to enter a sales amount in with the code and not to be entered by the user.
Here is the error I am receiving:
! variable sales might not have been initialized
Here is my current code:
PS: this is homework and I am not asking for it to be done, but just please point out how to add in where users enter in the sales and the compensation will equal itself out.
Thank you for your time and concern.
However all my attempts leave me where I need to enter a sales amount in with the code and not to be entered by the user.
Here is the error I am receiving:
! variable sales might not have been initialized
Here is my current code:
import java.io.*; import java.util.Scanner; public class Commissions123 { public static void main(String[] args) { double sales; double commission = 0.4; double salary = 80000.00; double compensation; compensation = calculation(sales, commission, salary); System.out.println("Compensation: " + compensation); } private static double calculation(double sales, double commission, double salary) { double compensation = 0.0; double salesWcommission = sales + (sales * commission); compensation = salary - (sales * commission); return compensation; } }
PS: this is homework and I am not asking for it to be done, but just please point out how to add in where users enter in the sales and the compensation will equal itself out.
Thank you for your time and concern.