reset password
Author Message
KA1997
Posts: 31
Posted 21:10 Feb 18, 2017 |

How do you convert user input 1 to 13 and 2 to 14 in HW04P03?

Arnav98
Posts: 48
Posted 21:12 Feb 18, 2017 |

Thats basic math. Just add 12 to both the values and store it in a new variable.

KA1997
Posts: 31
Posted 22:26 Feb 18, 2017 |

So it would be something like

"if (m == 1 && m==2) {
            in m = m+12
        }" ?

sdo8
Posts: 54
Posted 23:15 Feb 18, 2017 |
KA1997 wrote:

So it would be something like

"if (m == 1 && m==2) {
            in m = m+12
        }" ?

that implies that m is equal to 2 numbers at the same time. Try it out yourself and see what kind of output you get. I'm pretty sure that might be a run time error. You'd be much better off using ||.

jgarc629
Posts: 76
Posted 01:22 Feb 19, 2017 |
KA1997 wrote:

So it would be something like

"if (m == 1 && m==2) {
            in m = m+12
        }" ?

This looks like a scenario where if either m == 1 _____ m == 2 then you would want the value added by 12. Looks like these statements can be combined with any of these: AND OR XOR. It seems here that at least one of your statements must be true in order for this whole thing to be true. Review your notes to see which one fits best and try it out. 

KA1997
Posts: 31
Posted 17:50 Feb 19, 2017 |

I tried the or "||". That fixed it and made the output correct.