Home Answers Viewqa Java-Beginners While loop break causing unwanted output

 
 


Jacob Quinn
While loop break causing unwanted output
0 Answer(s)      2 years ago
Posted in : Java Beginners

Below I will paste my code. My problem is that when I run this I get to input a int and if correct it will output that I was correct but after that it will output something that I'm not understanding which is"hack2@1f24bbbf". Any help will be greatly appreciated as I'm just beginning learning java.


import java.util.Scanner;
public class hack2 {
    public hack2 mathequation1;
        int answer = 10;
        int numc;
        int counter = 0;
        Scanner job = new Scanner(System.in);{

while(counter != answer){
    numc = job.nextInt();
    if(numc != answer){
    System.out.println("You are wrong");
    counter = numc;

}else{

    System.out.println("You are correct");}
    break;

}

}
}

View Answers









Related Pages:
While loop break causing unwanted output
While loop break causing unwanted output  Below I will paste my code... it will output that I was correct but after that it will output something that I'm...);{ while(counter != answer){ numc = job.nextInt(); if(numc != answer
break
use break.  It gives the following output: C:\javac>... statement terminates the innermost loop like switch, for, while, or do-while statement... the loop will continue and it will give the output as shown below. 
loop
to output the following code using a loop the code is as follows with the user..." CODE:"K19" QUANTITY:"1" CODE:"XX"   import java.util.*; class Output...(); System.out.print("Quantity: "); int quantity=input.nextInt(); while
PHP Break
helps us to break any loop or sequence, like if we want to break the flow of any loop (for, while etc) then we can use break statement, generally we need...) break; else echo "$a\t"; } ?> Output: 1 2 3 4 Example
Break Statement in JSP
early from the loop. It allows the program to escape from the for, while, switch and do while loops. A break may only appear on one... are using the switch statement under which we will use break statement. The for loop
Java Break while example
label mass.           Break While Loop Java... Java Break while example       Break is often used in terminating for loop but it can also
Break statement in java
control flow of  compound statement like while, do-while , for. Break... happen that we want to come out of the loop in that case break  is used. Break is used with for, while and do-while looping statement and break
While Loop Statement in java 7
and if condition satisfied then the while block executes otherwise break the loop... } } } Output : While loop example... Hello 1 Hello 2 Hello 3 Hello 4...While Loop Statement in java 7 This tutorial, helps you to understand
output
output  Sir,I am experiencing some problems with the output of this program.I got some useful help this website,but the output of the program isn't producing what it should.let me explain the output below is what happen when
C break continue example
to force an immediate jump to the loop control statement. The break statement... both the statements within the do while loop. The program prompts the user... statement skips the value and jumps to the do while loop without terminating the loop
C Break for loop
C Break for loop       In this section, you will learn how to use break statement in a for loop. The break statement terminates the execution of the enclosing loop
Java break for loop
Java break for loop      ... baadshah. In the example, a labeled break statement is used to terminate for loop... control outside the outermost loop.           Break
while & do..while Loop
while & do..while Loop while loop The while loop iterate until provided condition is true. Given below the syntax : while (condition)  ...; <?php $j=1; while($j<=3) { echo "Value of j" . $j . "<
while loop to for loops
("%-10s%-10s%n", "------","------"); //while loop to output 1- 10...%-13s%n",i,(i*i)); i++; } // while loop to output uppercase...while loop to for loops  I have to change this while loops
While loop Statement
While loop Statement  How to print a table using while loop?  ... +" = "); while(y<=10) { int t = x...++; } } } Output Table of 5 = 5 10 15 20 25 30 35 40 45 50
Java - Break statement in java
break statement and exit from the loop and loop is terminated. The break statement is used in while loop, do - while loop, for loop and also used in the switch... Java - Break statement in java     
While Loop with JOptionPane
While Loop with JOptionPane  Hello there, why the output only... int k = 5; String name; int age; while(i < k...[]=new String[5]; int arr[]=new int[5]; while(i < k){ String name
Break Statement in java 7
terminate the loop like while, do-while, for and switch. When you call break it jumps out of the recent specified loop. It breaks the innermost for, while, do... of your loop (do-while, while, for or switch statement). In switch statement we
Java Break out of for loop
Java Break out of for loop     ... it out of the loop. While 'continue' label just stops the program flow at line where... javax.swing.JOptionPane; public class Java_Break_out_of_for_loop
Java Break loop
statement is  used to break two looping statements do-while & for loop... are commented then  break; //this do while loop will become an infinite loop... Java Break loop      
php do while break
php do while break   receiving a Fatal saying cannot break/continue.. please suggest. Thank U
PHP While Loop
While Control Structure: While is the simplest form of loop. While loop checks..., and become infinite loop. While loop is also known as pre-test loop. Basic format of while loop is as follows: while(condition) expressions
Java Break
to the next statement following the loop statement. Break is one of the controlling statement like continue and return. Break statement can be used in while loop, do - while loop, for loop and in switch statement. Read more at: http
PHP Do While Loop
Do-While Loop Function PHP: PHP Do-While loop method is another type of loop... at least once despite of the validity of the variable. In Do-While loop we need... of the variable within the loop. PHP do while loop Example: <?php $i=34; do
adding loop
the loop is: > Blockquote import java.util.*; class Output { public... a loop can you help me?The program below is compiling without the loop. >...(); System.out.print("Quantity: "); int quantity=input.nextInt(); while
Continue and break statement
loop whereas the break statement causes the control outside the loop. Here... ; } } System.out.println("Termination by BREAK"); } } Output... then break statement will call and control will jump outside the current loop
using switch,break and for loop
using switch,break and for loop  generate a 10 digit number and display the length of longest increasing series
PHP Do While Loop
Do-While Control Structure: Do-While loop is another type of loop which runs... at least once despite of the validity of the variable. In Do-While loop we need... within the loop. Format of do-while loop is as follows: do{ statement; }while
While Loop in JSP
While Loop in JSP          The while loop is a control flow statement.... In while loop the condition is firstly evaluated, if it finds that the condition
Finding a Factorial using while loop
Finding a Factorial using while loop   ... are going to find out the factorial of 12 by using the while loop. In while loop... .Now use while loop and pass the condition that until temp> 0, the loop
Loop in java
on the following link to know all about it. While Loop in Java Do-While Loop in Java For Loop in Java Break statement in java Continue statement in Java... Loop is the control statement of any language in which whenever you want
Finding a Factorial using while loop
Finding a Factorial using while loop     ... the while loop. In while loop the loop will run until the condition we have given... to calculate the factorial .Now use while loop and pass the condition that until
java break to label tatement
void main(String[] args) { what: break what; // not an infinite loop...Java Break to Label Statement In this article author discusses about Java Break to label Statement. 2005-06-30 The Java Specialists' Newsletter [Issue 110
The break Keyword
a for, while, or do loop or to mark the end of a case block in a switch statement. Also break keyword is used for terminate a loop. The break always exits an innermost enclosing while, for, do or switch statement. The break statement
Java Break Lable
. In the example a label String value 'weisz' is defined above the outer most loop while... the while loop under the label weisz.           Code... Java Break Lable      
Java Break continue
Java Break continue       Java has two keywords break and continue in its branching category. 'break' allows users to give end to a loop whereas with 'continue
php array loop while
php array loop while  Using the php array while loop
PHP While Loop
While Loop in PHP: In programming language we need to use loops for executing... Loop in PHP: While loop checks the condition first and if it is true... the condition to stop, and become infinite loop. While loop is also known as pre-test
How to write a loop and a while loop
How to write a loop and a while loop  How do I write a 1 loop and a 1 while loop for the example code: public boolean isTheFirstOneBigger (int num1, int num2) { if (num1 > num2) { return true
Java Break command
Java Break command       Java Break command is commonly used in terminating looping statements. break command comes under the Java branching statements category. In programming
php do while loop
php do while loop  Difference between do while loop and simple loop in PHP
While loop Statement.
While loop Statement.   How to Print Table In java using While Loop
php while loop
php while loop  Example to fetch the data using while loop in PHP
HTML line break tag
. While displaying the web page browser will add a line break where it finds...HTML line break tag. The HTML Line break tag <br> is used to add a line break in web page. You can use the <br> tag to add line break in your
Memory leak in While loop
Memory leak in While loop  How to manage a memory leak in While loop ?   make sure loop is not running infinitley...;make sure loop is not running infinitley
The while and do
it will continue the next statement and will exit the while loop. The output... Bonjour The while statement works as to for loop because the third...) } while (expression); Lets tweak an example of do-while loop
loop
loop  what is the difference b/w do while,while and for loop..with example
do-while loop
do-while loop  how many times will the following loop get executed and what will be the final value of the variable I after execution the loop is over. int I = 5; do{ I + = 3; System.out.println(""+I); I=I+1; }while(I>=9
while loop handling
while loop handling  Dear deepak, thanks for your response yesterday.. I am doing a project on travelling domain.. in that initially i searched all... option the while loop always taking tyhe last flight datails only... and in all
Java find prime numbers without using break statement
. In many of the programs, break statement is used to quit the loop. Actually this break statement transfer the control at the end of the loop. This tutorial...Java find prime numbers without using break statement In this tutorial, you

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.