Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2013
    Posts
    1
    Rep Power
    0

    Post I can't get rid of this bug ,help me please

    Java Code:
    import java.util.Scanner;
    public class javaproject14 {
    
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		String gender;
    Scanner in = new Scanner(System.in);
    System.out.println("what is your gender?");
    gender = in.nextLine();
    System.out.println("what is your balance?");
    int balance = in.nextInt();
    if(gender == "female"){
    	if(balance>5000){
    		System.out.println("your bonus is "+.05*balance);
    	}else
    		System.out.println("your bonus is "+.02*balance);
    }else
    	System.out.println("bonus is "+.02*balance);
    	}
    
    }
    Last edited by JosAH; 08-11-2013 at 07:41 AM. Reason: added [code] ... [/code] tags

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    2,924
    Rep Power
    4

    Default Re: I can't get rid of this bug ,help me please

    Please read the following and also edit your post using code tags. You also need to explain what problems you are having.

    Guide For New Members
    BB Code List - Java Programming Forum - Learn Java Programming

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,000
    Blog Entries
    7
    Rep Power
    20

    Default Re: I can't get rid of this bug ,help me please

    I added those code tags for the OP. (it's the beginners mistake of == vs String.equals( ... ))

    kind regards,

    Jos (the Site Janitor)
    cenosillicaphobia: the fear for an empty beer glass

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
  •