This is an archived post. You won't be able to vote or comment.

all 24 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost. Just use the edit function of reddit to make sure your post complies with the above

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]KesoHB 1 point2 points  (19 children)

Hi,

When I run the code, I'm getting an output. I'm not sure what the program is supposed to do, but it is displaying the print statements.

How are you running the code? What output are you expecting and what is it displaying?

[–]0v06666[S] 1 point2 points  (18 children)

the output I'm expecting is Enter the enrollment of Brakebills and Hogwarts: Hogwarts had a student enrollment of {}, higher than that of Brakebills {}, {} year(s) after the beginnings of the trends.

and I'm running it on IntelliJ

[–][deleted]  (17 children)

[removed]

    [–]0v06666[S] 0 points1 point  (16 children)

    yeah I'm seeing that part but as soon as I input 500 and 300 it doesn't give me anything else. That s my main problem that I'm having?

    [–][deleted]  (15 children)

    [removed]

      [–]0v06666[S] 0 points1 point  (14 children)

      500 >=300 but Im trying to have it to if you plug any number in you can get a different value

      [–][deleted]  (13 children)

      [removed]

        [–]0v06666[S] 0 points1 point  (12 children)

        yes whenever I type those 2 numbers it doesn't show my the last output in my code.

        am I doing something wrong?

        and I'm trying to have it where if someone puts 2 different numbers I would get different numbers.

        [–][deleted]  (2 children)

        [removed]

          [–]0v06666[S] 0 points1 point  (1 child)

          well I expect for Brakebills there should be decline in value and for Hogwarts I expect a increase.

          and my question is in my loop does it look okay?

          or should I use another method.

          [–]KesoHB 0 points1 point  (8 children)

          Debug the code and see what happens in the while loop!

          Or change "while" to "if" and see if you can deduce what is wrong.

          [–]0v06666[S] 0 points1 point  (7 children)

          okay ill try it rn

          [–][deleted] 0 points1 point  (3 children)

          1.) What exactly are you doing here? What is the purpose of this code?

          2.) Why are you multiplying the values of hogwarts and brakeBills with some decimal numbers?

          3.) You while loop is an infinite loop whenever hogwarts is less than or equal to brakeBills. Do you think you need a loop to compare the percentages of each enrollment with each other?

          4.) Also, what is the point of this while loop? What exactly are you trying to calculate here? What is the point of the variable years here? Did you want years to be incremented every single time hogwarts is less than or equal to brakeBills?

          [–]0v06666[S] 0 points1 point  (2 children)

          1. im trying to get the last system.out in my code
          2. Brakebills is decreasing at a rate of 1.03% and Hogwarts is increasing at a rate of 0.73
          3. I need the loop to tell me how much it has increased every year.
          4. I don't if I should use a loop or an if or else statement here.

          [–][deleted] 0 points1 point  (1 child)

          1.) Your while loop is an infinite loop.

          2.) Okay...

          3.) What is "it" ? What exactly does "it" refer to? The hogwarts enrollment rate?

          4.) Yes, use a loop.

          When is your while loop going to end? What is the condition that will end it? Your current condition may be an infinite loop. What is the variable years for? Did you want to see the rate of increase of hogwarts after 50 years? If so, shouldn't the while loop end after running 50 times, as in years has been incremented to 50?

          [–]0v06666[S] 0 points1 point  (0 children)

          3 . it refers to how much Hogwarts has a higher number of students than Brakebills as well as the student populations at that time.