CONDITION 1: while ( !(cChoice == 'Q' || cChoice == 'q') )
CONDITION 2: while ( cChoice != 'Q' || cChoice != 'q' )
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
CONDITION 1: while ( !(cChoice == 'Q' || cChoice == 'q') )
CONDITION 2: while ( cChoice != 'Q' || cChoice != 'q' )
Last edited by senicamarcus; April 28th, 2014 at 08:15 PM. Reason: Learning something new
what is the question?
Do Conditions 1 and 2 give the same result? What tool or technique would you use to explain the result?
not always. It depend on the value of cChoice. I assumed that you have jdk installed in you computer and you know how to create a simple program, so you can try it on yourself. just print their values giving a different value in your cChoice.
System.out.println(!(cChoice == 'Q' || cChoice == 'q'))
System.out.println(cChoice != 'Q' || cChoice != 'q')
but first, declare a value for your cChoice. after compiling and running it, try another value for cChoice. Then after that, you can draw a conclusion of your own.
senicamarcus (April 28th, 2014)
That's the same result i was getting...I wanted to make sure i was sane...
Look at De Morgan's law
If you don't understand my answer, don't ignore it, ask a question.