Welcome to Dream.In.Code
Getting Java Help is Easy!

Join 136,263 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,200 people online right now. Registration is fast and FREE... Join Now!




loop help

 
Reply to this topicStart new topic

loop help

tgrsnpr
13 Oct, 2008 - 11:51 PM
Post #1

New D.I.C Head
*

Joined: 10 Oct, 2008
Posts: 11

I got it to loop but whenever I click enter it just gives an empty line. I want it to stop reading and go to the part where you type in document you wanna use.
CODE

  public static void main(String[] args) {
    
    //what it does
    System.out.println("This program will average a series of numbers.");

    Scanner keybd = new Scanner(System.in);

    Boolean keepGoing = true;

    while(keepGoing) {
        System.out.print("Enter an integer (or nothing to stop): ");
        int number = keybd.nextInt();
    }
    if (keepGoing.equals("")) {
        System.out.println();
    }
  }
}

User is offlineProfile CardPM
+Quote Post

Gloin
RE: Loop Help
14 Oct, 2008 - 02:38 AM
Post #2

On MeD.i.Cation
Group Icon

Joined: 4 Aug, 2008
Posts: 723



Thanked: 47 times
My Contributions
Still the same problem as before. I explained this already and even gave you some code to use.
User is offlineProfile CardPM
+Quote Post

tgrsnpr
RE: Loop Help
14 Oct, 2008 - 02:46 AM
Post #3

New D.I.C Head
*

Joined: 10 Oct, 2008
Posts: 11

QUOTE(Gloin @ 14 Oct, 2008 - 03:38 AM) *

Still the same problem as before. I explained this already and even gave you some code to use.


I've tried using them. But it doesn't work. I've even tried emailing my teacher for help and I'm not understanding what the heck he's telling me to do. Loop is just one thing that stumbles me.
User is offlineProfile CardPM
+Quote Post

Gloin
RE: Loop Help
14 Oct, 2008 - 03:03 AM
Post #4

On MeD.i.Cation
Group Icon

Joined: 4 Aug, 2008
Posts: 723



Thanked: 47 times
My Contributions
Google for java + loop
or
java + for
or
java + while

Because you could really benefit from seeing some examples of how loops work.

if (keepGoing.equals("")) {
System.out.println();
}

The above code is completely irrelevant and not even part of the loop.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 04:40AM

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month