11.1k views
1 vote
Write one or more C statements that assign the correct value to discount, using the logic described here:

1. Assign .20 to discount if dept equals 5 and price is $100 or more.
2. Assign .15 to discount if dept is anything else and price is $100 or more.
3. Assign .10 to discount if dept equals 5 and price is less than $100.
4. Assign .05 to discount if dept is anything else and price is less than $100.

User Jabongg
by
6.6k points

1 Answer

6 votes

Answer:

See Explanation

Step-by-step explanation:

To solve this, I'll skip variable declarations

if (dept == 5 && price >= 100){//1

discount = 0.20;

}

else if (price >= 100){ //2

discount = 0.15;

}

else if (dept == 5 && price < 100){//3

discount = 0.10;

}

else if (price < 100){//4

discount = 0.05;

}

The question requires if conditional statements and that has been shown in the above lines of code

Also, the comments (//) indicates the number of each line and it does exactly what is required.

User Syed Ahmed Jamil
by
6.6k points