This site requires JavaScript, please enable it in your browser!
Greenfoot back
Mspassion00
Mspassion00 wrote ...

2013/1/25

Please help?

Mspassion00 Mspassion00

2013/1/25

#
Would you please take a look at this answer ... to see what I am doing wrong? Any suggestions? Please help me determine how it should be written correctly? Am I missing semicolom -- for the if/else statement? Thanks! soldToday -1> = if {(soldYesterday) } else (salesTrend);
danpost danpost

2013/1/25

#
The proper syntax for an 'if' statement is if (condition) trueStatement; else falseStatement; or if (condition) { trueBlockStatement1; trueBlockStatement2; // etc. } else { // false statements } I cannot even determine what you are trying to do with the statement you gave because of the way it was coded.
Mspassion00 Mspassion00

2013/1/25

#
Thanks! danpost. Here is the question. maybe this will help. My response is still incorrect. Any suggestions? Question: Write an if/else statement that compares the value of the variables soldYesterday and soldToday , and based upon that comparison assigns salesTrend the value -1 or 1 . -1 represents the case where soldYesterday is greater than soldToday ; 1 represents the case where soldYesterday is not greater than soldToday . My responses: they are both wrong; I can't figure out what is missing or in the wrong place: soldToday -1> = if {(soldYesterday) } else (salesTrend);
danpost danpost

2013/1/25

#
What you are saying is: if soldYesterday is greater than soldToday, then salesTrend is assigned negative one else salesTrend is assigned one. If you know how to assign a value to a variable then these would be your 'trueStatement' and 'falseStatement' replacements and 'condition' is replaced with your comparison expression. Hope that helps. If you still cannot get it to work, post the code you have now for more help.
You need to login to post a reply.