62.6k views
4 votes
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.

User Boris
by
4.8k points

1 Answer

5 votes

Answer:

if(soldYesterday > soldToday){

salesTrend = -1;

} else if(soldToday > soldYesterday){

salesTrend = 1;

}

Step-by-step explanation:

The if/else statement is more explicit. The first if condition check if soldYesterday is greater than soldToday, if true, then -1 is assigned to salesTrend.

Else if soldToday is greater than soldYesterday, if true, then 1 is assigned to salesTrend.

User Abhisek Malakar
by
4.9k points