Results 1 to 9 of 9
  1. #1
    jjfstar2009 is offline Member
    Join Date
    Apr 2014
    Posts
    21
    Rep Power
    0

    Post Java While Loop Question

    Write a java program that uses a While loop and persistent output to count down from 33 to 0 by threes, and put each value on a separate line, also do this in for loop. Please Help!

  2. #2
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Java While Loop Question

    Hi,

    if you have no clue on how to start, then simply read the course material. Or read some java introductions that explain how to write an application, how to write a while loop and a for loop.

    Then try to write the application yourself and if you run into problems: Feel free to come back and show us your code and explain the problem. Then we might be able to help you.

    With kind regards,

    Konrad

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,029
    Rep Power
    6

    Default Re: Java While Loop Question

    Do you also run through the streets shouting "HELP! HELP!" without being in any kind of trouble? There is no problem to get help with here.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

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

    Default Re: Java While Loop Question

    Quote Originally Posted by gimbal2 View Post
    Do you also run through the streets shouting "HELP! HELP!" without being in any kind of trouble?
    Yep; on a weekly basis when I run out of Grolsch or tobacco, why ask?

    kindest regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    jjfstar2009 is offline Member
    Join Date
    Apr 2014
    Posts
    21
    Rep Power
    0

    Default Re: Java While Loop Question

    public class loopTester
    {
    public static void main (String [] args){
    for (int i=30;i>=0;i--){
    System.out.println("Print " +i);
    }
    }
    }
    I got the for loop thanks for the comments you guys haha

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,029
    Rep Power
    6

    Default Re: Java While Loop Question

    Quote Originally Posted by JosAH View Post
    Yep; on a weekly basis when I run out of Grolsch or tobacco, why ask?

    kindest regards,

    Jos ;-)
    I wasn't asking you, everyone knows -you- do that. Its just an accepted thing of the town drunk.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    jjfstar2009 is offline Member
    Join Date
    Apr 2014
    Posts
    21
    Rep Power
    0

    Default Re: Java While Loop Question

    sorry meant for (int i=30;i>=0;i=i-3)

  8. #8
    jjfstar2009 is offline Member
    Join Date
    Apr 2014
    Posts
    21
    Rep Power
    0

    Default Re: Java While Loop Question

    public class WhileLoop
    {
    public static void main(String [] args){
    int i=33;
    while (i>=0){
    System.out.println("Print " +i);
    i = i-3;
    }
    }
    }


    :D

  9. #9
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Java While Loop Question

    Great - so you got both solved now.

    But just check the solutions if you really get the expected result - starting with 33 and including the 0.
    (So you might want to change the for loop a little bit - but maybe it was just inside the forum and not in your code at home.)

    With kind regards,

    Konrad

Similar Threads

  1. Little question about do while loop need help :)
    By Stanimir in forum New To Java
    Replies: 3
    Last Post: 03-19-2014, 03:20 PM
  2. Question With a loop
    By zniightmare in forum New To Java
    Replies: 14
    Last Post: 02-08-2012, 06:46 PM
  3. Do....while Loop question
    By Roter in forum New To Java
    Replies: 10
    Last Post: 01-25-2012, 04:49 AM
  4. Loop question
    By rich123 in forum New To Java
    Replies: 6
    Last Post: 02-08-2011, 02:26 AM
  5. for Loop with Yes/No Question! help..please!
    By mastercrimson in forum New To Java
    Replies: 8
    Last Post: 06-02-2010, 05:08 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
  •