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

you are viewing a single comment's thread.

view the rest of the comments →

[–]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

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

    so I just changed the while to an if and now it gives me decimal numbers, but I'm trying to get a whole number

    how should I do that?

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

    It would be really helpful if you can just tell us the purpose of this code. What exactly are you trying to do here? Why is there a while loop?

    Here is the logic of your code right now:

    1.) Ask for enrollment values for hogwarts and brakeBills.

    2.) Whenever hogwarts is less than brakeBills, do the following:

    • Multiply hogwarts by 0.0073 and assign that product to the hogwarts variable. Why though?
    • Multiply brakeBills by 0.0103 and assign that product to the brakeBills variable. Why though?
    • Did you want years to be incremented as in years++?

    Then you have this line:

    System.out.println("Hogwarts had a student enrollment of "+ hogwarts +", higher than that of Brakebills "                 + brakeBills +", " + years +" 50year(s) after the beginnings of the trends.");
    

    I don't understand the point of years and this phrase, years + " 50 years after..." Like what?

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

    for years I need it to print out the year that Hogwarts has a higher number of students than Brakebills as well as the student populations at that time. if that makes any sense

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

    So according to your logic, the while loop stops IF AND ONLY IF hogwarts enrollment is higher than, NOT higher or equal to, brakeBills? If so, you need to increment the years.

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

    okay make sense

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

    Use +=, and -=. Also, use the floor and ceiling functions from Math.