Question

My program passes through the if statements as if they weren't there. Anything to look out...

My program passes through the if statements as if they weren't there. Anything to look out for?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The operator inside the if statement should be OR operstor instead of AND operator.

The if statement reflects that the number should be less than 1 and also should be grater than 15 at the same time which is not possible. Hence, the compiler never executes the if statement.

So, the if statement should be

if( (userInputInt < 1) || (userInputInt > 15) )

The if statement now reflects that the number should be less than 1 or should be grater than 15 which is possible.

Add a comment
Know the answer?
Add Answer to:
My program passes through the if statements as if they weren't there. Anything to look out...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • need a program that translates seconds into anything it has to look like this at the...

    need a program that translates seconds into anything it has to look like this at the bottom . class is visual C# and if you can help with the program and also the button and labels used would be helpful 11:53 vil LTE ID Assignment-4-B.PNG m4_11.Form! components Program4_12 Enter a number of seconds 365 Calculate ainer co 6 minutes 5 seconds managed resources should be disposed; otherwise, false.</param> - disposing) null)) -OX Call Stack Carl Frente

  • 12. Write out the sequence of events when light passes through our pupil and ends in...

    12. Write out the sequence of events when light passes through our pupil and ends in acknowledging the object we are viewing. 13. Name and define the stages of processing for our special senses.

  • 4) Look again at Equation 4.79. Assume light passes through a gas that has no free...

    4) Look again at Equation 4.79. Assume light passes through a gas that has no free electrons and for low frequency light has only 1 important resonance frequency. Only one term in Eq. 4.79 will then be important (not the free electron term). Using this model, consider the index of refract of an ideal gas, where each molecule has a single resonance state. Assume the only resonance frequency is hw-leV.For gas at standard temperature and pressure and for wave length...

  • .01 points Previous Answers Se5 38.P41 My Nates Ask Youi Unpolarized light passes through two polaroid...

    .01 points Previous Answers Se5 38.P41 My Nates Ask Youi Unpolarized light passes through two polaroid sheets. The axis of the lirst is vertica, and that ol the second is at 36,0 to the verticalat fraction of the initial light is transmitted? 0.40

  • .)   Write a program to implement the exception handling with multiple (at least 3) catch statements....

    .)   Write a program to implement the exception handling with multiple (at least 3) catch statements. Any type of exception may be thrown. Catch statements must display (cout) the type of exception thrown. .)   Write a function which accepts an index and returns the corresponding element from an array. If the index is out of bounds, the function should throw an exception. Handle this exception in "main()". (This is pretty open ended, so anything from a calculator or "what have...

  • Write a program that will take a line of input and go through and print out...

    Write a program that will take a line of input and go through and print out that line again with all the uppercase letters swapped with the lowercase letters. JAVA

  • I'm having trouble with my program. My goal is to iterate through the array and add...

    I'm having trouble with my program. My goal is to iterate through the array and add only the even values together. When I run this program it hangs and I don't know why.    .text    .globl main main:    lui $16,0x1000    lw $17,0($16) addiu $16, $16, 0    addiu $18, $0, 2    addiu $19, $0, 28    loop: beq $16, $19, exit    div $17, $18    mfhi $13    beq $13, $0, even    addiu $16,...

  • Newmultiply.Java // NewMultiply.java - This program prints the numbers 0 through 10 along // with these...

    Newmultiply.Java // NewMultiply.java - This program prints the numbers 0 through 10 along // with these values multiplied by 2 and by 10. // Input: None. // Output: Prints the numbers 0 through 10 along with their values multiplied by 2 and by 10. public class NewMultiply {    public static void main(String args[])    {               String head1 = "Number: ";        String head2 = "Multiplied by 2: ";        String head3 = "Multiplied...

  • Another simple sort is the odd-even sort. The idea is to repeatedly make two passes through the a...

    Another simple sort is the odd-even sort. The idea is to repeatedly make two passes through the array. On the first pass you look at all the pairs of items, a[j] and a[j+1], where j is odd (j = 1, 3, 5, …). If their key values are out of order, you swap them. On the second pass you do the same for all the even values (j = 2, 4, 6, …). You do these two passes repeatedly until...

  • I am not creating my own cryptography or anything, but to learn about the Dos and...

    I am not creating my own cryptography or anything, but to learn about the Dos and Donts of cryptography, I am looking into AES encryption and ways to generate keys for that. As far as I've understood, one of the options to create cryptographically secure keys would be to gather entropy from /dev/urandom/ and then feed that data through the Salsa20 cipher. But I am unsure about the next step, because that

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT