|
-
September 22nd, 2017, 08:18 PM
#1
if/else statement
2017-09-22.jpg2017-09-22 (1).jpg
I'm a student and I have no clue what's wrong with my statement, it's not a compilation error because it just asks for the statement. The errors I get are that salesTrend does not have the proper value assigned and that I did not modify salesTrend. The test case table returns everything correctly except when soldYesterday and soldToday are equal. Any help is appreciated, sorry if this seems like a silly mistake.
-
September 23rd, 2017, 02:20 AM
#2
Re: if/else statement
Sorry, but I can't read the code on the images - nor the exercise requirement. Please copy and paste the code into a post using code tags so that the code is readable and also the requirement.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
September 23rd, 2017, 02:26 AM
#3
Re: if/else statement
 Originally Posted by se7enteenblack
I'm a student and I have no clue what's wrong with my statement, it's not a compilation error because it just asks for the statement. The errors I get are that salesTrend does not have the proper value assigned and that I did not modify salesTrend. The test case table returns everything correctly except when soldYesterday and soldToday are equal. Any help is appreciated, sorry if this seems like a silly mistake.
I agree with 2kaud. 
And you might want to read the Announcement: Before you post.... section.
Victor Nijegorodov
-
September 24th, 2017, 08:40 AM
#4
Re: if/else statement
Read the assignment and read your code. You've assigned three possible values to salesTrend. The assignment only calls for two.
-
September 24th, 2017, 11:33 PM
#5
Re: if/else statement
 Originally Posted by se7enteenblack
except when soldYesterday and soldToday are equal
Note that the logical negation of (a<b) is (a>=b) so,
Code:
if (a<b) {
// the (a<b) case
} else {
// the (a>=b) case
}
These are the two cases the exercise asks you to distinguish (and not to also separate out the equality (a==b) case).
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|