program to calculate gross salary

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neha123
    New Member
    • May 2016
    • 3

    program to calculate gross salary

    import java.util.*;
    class emp
    {
    int eno;
    String ename;
    int ddob, mdob, ydob, ddoj, mdoj, ydoj, yoe, cyear;
    double basic, hra, trans, medi, cbonus, ded, gsal;
    double cbonus( int yoe)
    {
    if(yoe>=10)
    cbonus=basic*0. 10;
    else if(yoe>=5 && yoe<=9)
    cbonus=basic*0. 07;
    else if(yoe>=2 && yoe<=4)
    cbonus=basic*0. 05;
    else
    cbonus=basic*0. 03;
    return(cbonus);
    }

    double ded( double basic)
    {
    if(basic>=500)
    ded=basic*0.10;
    if(basic>=300 && basic<500)
    ded=basic*0.06;
    else
    ded=basic*0.03;
    return (ded);
    }

    int yoe(int ydoj)
    {
    yoe=cyear-ydoj;
    return(yoe);
    }

    double gsal()
    {
    gsal=basic+hra+ trans+medi+cbon us-ded;
    return(gsal);
    }

    public class prgrmnew
    {
    static Scanner console=new Scanner(System. in);
    public static void main(String args[])
    {

    double[] a = new double[5];



    }
    }
    }
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    I can see a source code dump. What's the problem?

    Comment

    • neha123
      New Member
      • May 2016
      • 3

      #3
      i am not able to declare an array and proceed as it shows errors. Pardon me for the codes as I'm still working on it.

      Comment

      • johny10151981
        Top Contributor
        • Jan 2010
        • 1059

        #4
        What line? What does the error says?

        Comment

        • neha123
          New Member
          • May 2016
          • 3

          #5
          the line that includes the static scanner and the next line.
          it says inner classes cannot contain static declarations.

          Comment

          • chaarmann
            Recognized Expert Contributor
            • Nov 2007
            • 785

            #6
            You made your class "prgrmnew" an inner class, but method main() should be in an "outside" class. Then you can define your static scanner.
            To change your code just move the last closing curly bracket BEFORE this class "prgrmnew".

            Hint: Use code tags surrounding your listing, so I can answer better by referring to a line number
            And please use meaningful names! "prgrmnew" is in no way acceptable. Use camelCase and no abbreviations. Classes start with capital letter. So "NewProgram " would be a correcly named class name, although not meaningful. Just say what it is! I just guess "EmployeeBonusC alculator".

            Comment

            Working...