Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2015
    Location
    new delhi, India
    Posts
    3
    Rep Power
    0

    Exclamation need help in simple code

    i just wrote this code, but there is an error saying: " ';' expected public void show() _


    here is the code, guys plz help in removing this these little things irritate me a lot.




    import java.util.Scanner;
    public class GrossSalary
    {
    public void show()
    int sal,gs;
    {
    Scanner sc = new Scanner(System.in);
    sal=sc.nextInt();
    }

    public static void main(String[] args)
    {
    if(sal<1500)
    {
    gs=sal+(0.1*sal)+(0.9*sal);
    System.out.println("Gross Salary"+gs );
    }
    else
    {
    gs=sal+500+(0.98*sal);
    System.out.println("Gross Slary"+gs);
    }
    }
    }

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: need help in simple code

    What should irritate you is that you don't listen to the compiler. It is trying to help you.

    Java Code:
    public void show()
    int sal,gs;        // <--- wrong
    {                   // <--- reversed these two lines
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: need help in simple code

    Quote Originally Posted by pradyumnparmar View Post
    need help in simple code
    Please go through the Forum Rules, particularly the third paragraph.

    Also, I see you didn't bother to return to the first thread you started. Not the best way to continue getting free help on a forum, that.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: need help in simple code

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Join Date
    Jul 2015
    Location
    new delhi, India
    Posts
    3
    Rep Power
    0

    Default Re: need help in simple code

    yup, sorry for dt....i'll take care of things next time........BTW thanks for d suggestions

Similar Threads

  1. Is there anyone who can example simple code
    By Grkn in forum Reviews / Advertising
    Replies: 2
    Last Post: 10-16-2011, 03:35 AM
  2. need a simple code for the following
    By payal in forum New To Java
    Replies: 3
    Last Post: 09-14-2011, 01:24 AM
  3. Simple code. Could you help pls..?
    By Iliyas in forum New To Java
    Replies: 8
    Last Post: 12-26-2008, 03:17 AM
  4. Simple code help
    By rednose in forum New To Java
    Replies: 11
    Last Post: 11-30-2008, 06:02 AM
  5. simple code
    By elizabeth in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 06:49 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •