Note that there are some explanatory texts on larger screens.

plurals
  1. POjava while statement error
    primarykey
    data
    text
    <p>hi this is my code :</p> <pre><code> import java.util.Scanner; public class Calc { public static void main(String[] args) { Scanner sc = new Scanner (System.in); int a,b; String rep="YES"; while (rep.equals("YES")){ System.out.println("Please enter your first number: "); a=sc.nextInt(); System.out.println("Please enter you second number: "); b=sc.nextInt(); int c=a+b; System.out.println("The sum of a and b is: "+c); rep=" "; while (!rep.equals("YES") &amp;&amp; !rep.equals("NO")){ System.out.println("Would you retry ( YES/NO): "); sc.nextLine(); rep=sc.nextLine(); } } System.out.println("Thanks to use mY proggram!"); }} </code></pre> <p><strong>My probleme in this code : When i run this app , Firstly :</strong></p> <p>Please enter your first number: </p> <p>45</p> <p>Please enter you second number: </p> <p>45</p> <p>The sum of a and b is: 90</p> <p>Would you retry ( YES/NO):</p> <p><strong>I write something else like "dgdg" That would be</strong> </p> <p>Please enter your first number: </p> <p>45</p> <p>Please enter you second number: </p> <p>45</p> <p>The sum of a and b is: 90</p> <p>Would you retry ( YES/NO): </p> <p>dgdg</p> <p>Would you retry ( YES/NO): </p> <p><strong>this time when i write "YES" it appears another line to write something like this :</strong></p> <p>Please enter your first number: </p> <p>45</p> <p>Please enter you second number: </p> <p>45</p> <p>The sum of a and b is: 90</p> <p>Would you retry ( YES/NO): </p> <p>dgdg</p> <p>Would you retry ( YES/NO): </p> <p>YES</p> <p>YES</p> <p>Please enter your first number: </p> <p><strong>hope to find a solution</strong> </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload