Results 1 to 6 of 6
  1. #1
    reglosk is offline Member
    Join Date
    Aug 2013
    Posts
    1
    Rep Power
    0

    Post New to java, need help on a bug first program.

    Hey guys I'm very new to java and fairly new to programming. I started learning java a few weeks ago and so far I'm doing alright, I've managed to write a program that calculates the areas or parameters of shapes, and I made a loop that asks the user if they wanted to make another calculation. but i came across a bug that outs the same string twice. I've tried searching through the code but i guess reading the code is more trivial to me than writing it atm. any help would be much appreciated.
    Attached Thumbnails Attached Thumbnails New to java, need help on a bug first program.-java-calc-bug.png  
    Attached Files Attached Files

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: New to java, need help on a bug first program.

    Please go through the Forum Rules, particularly the third paragraph.

    Also go through the Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming . Then post your code and any error messages on the forum.


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

  3. #3
    superhaNds is offline Senior Member
    Join Date
    Apr 2013
    Location
    Sweden
    Posts
    268
    Rep Power
    2

    Default Re: New to java, need help on a bug first program.

    Next time you would want to show the code instead.

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: New to java, need help on a bug first program.

    Posting your code will help but I'm guessing it has to do with the Scanner class. There have been numerous posts explaining the problem so you can search for a more detailed explanation and solution. Basically when you call nextInt it only reads the int and not the carriage return. Then you call nextLine and it reads the carriage return and returns an empty String.

  5. #5
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

    Default Re: New to java, need help on a bug first program.

    I don't know where the problem is .. But I do suggest you to read about Scope of variables ... Form your coding I am sure that you don't know whats going on... You can use boolean leterals directly in your code i.e no need of == true, For string comparison without defining two string for upper and lower case separately, you can use string.equalsIgnoreCase(anotherString) . For you problem my guess is that there is something wrong with your logic.Please make a review.

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,771
    Blog Entries
    7
    Rep Power
    21

    Default Re: New to java, need help on a bug first program.

    Quote Originally Posted by allaudin View Post
    I don't know where the problem is
    I do: after readin an int or a double (using a Scanner object) the end-of-line sequence still needs to be read.

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 4
    Last Post: 11-21-2012, 02:19 PM
  2. Replies: 4
    Last Post: 07-30-2010, 01:25 PM
  3. execute java program within java program
    By popey in forum New To Java
    Replies: 2
    Last Post: 10-22-2009, 06:32 PM
  4. Replies: 0
    Last Post: 04-04-2008, 03:40 PM
  5. Replies: 0
    Last Post: 10-04-2007, 10:33 PM

Posting Permissions

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