there’s a problem that i couldn’t discover in the following code [duplicate]

here's a code for giving a person's salary after adding a commission depending on the amount of sales as you can see it's a Java language code when i tried it it said W might not have been initialized i don't know what's wrong so please help me and thanks in advance

import java.util.Scanner;

public class Something {
   public static void main(String[] args) {
   Scanner in = new Scanner(;
       int salary, amount ;
       double  W, AllSalary;
   System.out.println("Enter your Salary and Amount ");
   salary= in.nextInt();
   amount= in.nextInt();
       W = 4/100*amount;
   else if(amount<=400000){
       W = 5/100*amount;
   else if(amount>400000){
       W = 7/100*amount;
   else {
   AllSalary = W + salary;
   System.out.println("Commission is"+W);
   System.out.println("Salary is"+AllSalary);  

Read more here:

Content Attribution

This content was originally published by THeGaMeR1122 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: