Hello,
I want to check how many of the following statements are true? But I should do this without "decision making statements".
x>=0
x>y
x !=0
Thanks
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.
Hello,
I want to check how many of the following statements are true? But I should do this without "decision making statements".
x>=0
x>y
x !=0
Thanks
Can you write some pseudo code that would should what you want to do?want to check ... without "decision making statements".
What are "decision making statements" that you need to skip?
If a "check" is supposed to return true or false, how can that be done without making a decision?
If you don't understand my answer, don't ignore it, ask a question.
shervan360 (December 25th, 2020)
Are only the if and switch statements forbidden? What about the ternary statement?If a "check" is supposed to return true or false, how can that be done without making a decision?
Did the instructor give any hints?
If you don't understand my answer, don't ignore it, ask a question.
shervan360 (December 25th, 2020)
I don't have any hints.
Write a program that receives two numbers X and Y from the input. without decision making determine how many of the following statements are true?
x>=0
x>y
x !=0
--- Update ---
Is this a good idea?
int x, y; boolean first = ( x >= 0); boolean second = (x>= y);
Have you tried it? What happened?
The problem statement says: how many of the following statements are true?
I assume that means the answer will be a number. For example: 4 statements are true.
How do you count the number of true values?
If you don't understand my answer, don't ignore it, ask a question.