Question: library > COSC 1 4 3 7 : Introduction to Programming home > Detecting multiple features with branches CHALLENGE ACTIVITY 3 . 7 . 2

library > COSC 1437: Introduction to Programming home >
Detecting multiple features with branches
CHALLENGE
ACTIVITY
3.7.2: Detecting multiple features with branches.
522940.4067970 q3zqy7
Jump to level 1
Integers numBananas and dollars are read from input. A banana costs 3 dollars.
If numBananas is greater than or equal to 4, then declare and initialize int variable totalCost with the product of numBananas and 3.
If totalCost is less than or equal to dollars, then output "Bananas successfully purchased."
Otherwise, output "Not all bananas purchased."
If numBananas is greater than 26, then output "Now out of stock."
End each output with a newline.
Click here for examples
} else {
totalcost =0;
}
if(totalCost = dollars){
cout "Bananas successfully purchased." endl;
}
else {
cout "Not all bananas purchased." endl;
}
if(numBananas >26){
cout "Now out of stock." endl;
}
return 0 ;
1
2
3
2y Section 3.7- Cosc 1437: Introduction to Programming...
prary > COSC1437 : Introduction to Programming home > etecting multiple features with branches
6: Compare output
Input 106,267
Your output
Not all bananas purchased. Now out of stock.
7 : Compare output
Input ,6,10
Your output Not all bananas purchased.
X 8: Compare output
Input
221
Your output
Bananas successfully purchased.
Expected output This test case should produce no output
9: Compare output
Input
Your output
10: Compare output
Input ,61,183
 library > COSC 1437: Introduction to Programming home > Detecting multiple

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!