Question: library > COSC 1 4 3 7 : Introduction to Programming home > Detecting multiple features with branches CHALLENGE ACTIVITY 3 . 7 . 2
library COSC : Introduction to Programming home
Detecting multiple features with branches
CHALLENGE
ACTIVITY
: Detecting multiple features with branches.
qzqy
Jump to level
Integers numBananas and dollars are read from input. A banana costs dollars.
If numBananas is greater than or equal to then declare and initialize int variable totalCost with the product of numBananas and
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 then output "Now out of stock."
End each output with a newline.
Click here for examples
else
totalcost ;
iftotalCost dollars
cout "Bananas successfully purchased." endl;
else
cout "Not all bananas purchased." endl;
ifnumBananas
cout "Now out of stock." endl;
return ;
y Section Cosc : Introduction to Programming...
prary COSC : Introduction to Programming home etecting multiple features with branches
: Compare output
Input
Your output
Not all bananas purchased. Now out of stock.
: Compare output
Input
Your output Not all bananas purchased.
X : Compare output
Input
Your output
Bananas successfully purchased.
Expected output This test case should produce no output
: Compare output
Input
Your output
: Compare output
Input
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
