While loop break causing unwanted output



Share on Google+Share on Google+

Jacob Quinn
While loop break causing unwanted output
0 Answer(s)      5 years and 11 months 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"[email protected]". 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;


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



View Answers

Related Tutorials/Questions & Answers:
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
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
php do while break
php do while break   receiving a Fatal saying cannot break/continue.. please suggest. Thank U
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
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
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
php array loop while
php array loop while  Using the php array while loop
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
While loop Statement.
While loop Statement.   How to Print Table In java using While Loop
php do while loop
php do while loop  Difference between do while loop and simple loop in PHP
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 . "<
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
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
php while loop
php while loop  Example to fetch the data using while loop in PHP
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
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
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 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
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
While loop - Java Beginners
While loop  Given a number, write a program using while loop to reverse the digits of the number. Eg. the no. is 12345, should be written as 54321...(br.readLine()); int n=num; int rem=0; int rev=0; while(n!=0
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
While Loop
While Loop       Loop.... Loop makes your program readable, flexible and reliable. While loop: While loop... the statements or processes written under the while loop are executed otherwise ignored
how to display output on jsp from while loop of action class....actually i am retreiving the post from posts column from my sql.plz help.thnkss
how to display output on jsp from while loop of action class....actually i am retreiving the post from posts column from my sql.plz help.thnkss  how to display output on jsp from while loop of action class....actually i am
programes on while loop
programes on while loop   write a program to calculate sum of an entered digit write a program to find gcd and lcm of 2 positive integers   Java sum of digits Java Find LCM and GCD
Character count by while loop
Character count by while loop  Write the program to count the number of characters entered until a full stop (.)is keyed-in. Anyone there pls help with this question...   import java.io.*; import java.util.*; class
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
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
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
Using while loop to loop through a cursor
Using while loop to loop through a cursor  ... while loop to loop through a cursor'. The Example create a table Stu_Table... that establish the result set. The While loop check a condition
printing the following output using for loop
printing the following output using for loop  1 2 3 3 4 5 4 5 6 7
Java Spring Hibernate Struts Training ClassNotFoundException HttpRequestInterceptor java.lang.noclassdeffounderror: org/apache/http/httprequest noclassdeffounderror: org/apache/http/client/methods/httpurirequest java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient How do I resolve this Java Class not found exception? httpclient java.lang.NoClassDefFoundError Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java


Advertisement null