Home / Expert Answers / Computer Science / correct-me-pls-integer-variables-numbananas-and-allowance-are-read-from-input-a-banana-costs-2-dol-pa932

(Solved): correct me pls! Integer variables numBananas and allowance are read from input. A banana costs 2 dol ...



correct me pls!


Integer variables numBananas and allowance are read from input. A banana costs 2 dollars.
- If numBananas is less than 6 , ou

Ex: If the input is 827 , then the output is:
Successful purchase!
At least one item was purchased.
\[
12
\]
The first if-els

Ex: If the input is 827 , then the output is:
Successful purchase!
At least one item was purchased.
1
The first if-else state

The first if-else statement checks the number of bananas purchased.
If at least 6 bananas are purchased, then a nested if-els

Expected output
3: Compare output A
Input
Your output
4. Compare output \( \wedge \)
Input
Your output
5. Compare output \( \
Integer variables numBananas and allowance are read from input. A banana costs 2 dollars. - If numBananas is less than 6 , output "numBananas requires at least 6 to purchase:. - If numBananas is greater than or equal to 6 , then multiply numBananas by 2. - If the product of numBananas and 2 is less than or equal to allowance, output "Successful purchasel". - Otherwise, output "Need more money to purchase all.". - If allowance is greater than or equal to 2 , output "At least one item was purchased." End with a newline. Ex: If the input is 827 , then the output is: Successful purchase! At least one item was purchased. Ex: If the input is 827 , then the output is: Successful purchase! At least one item was purchased. The first if-else statement checks the number of bananas purchased. If at least 6 bananas are purchased, then a nested if-else statement compares the cost of the bananas to the amount of money read from input. Ex: If the input is 827 , then the output is: Successful purchase! At least one item was purchased. 1 The first if-else statement checks the number of bananas purchased. If at least 6 bananas are purchased, then a nested if-else statement compares the cost of the bananas to the amount of money read from input. Next another nested if statement comnares the amount of monev rear from innut to the cost of nne hanana The first if-else statement checks the number of bananas purchased. If at least 6 bananas are purchased, then a nested if-else statement compares the cost of the bananas to the amount of money read from input. Next, another nested if statement compares the amount of money read from input to the cost of one banana. Not all tests passed. 1. Compare output Input Your output Compare output Output differs. See highlights below. Input Expected output numbananas requires at least 6 to purchase. Expected output 3: Compare output A Input Your output 4. Compare output Input Your output 5. Compare output Input Your output


We have an Answer from Expert

View Expert Answer

Expert Answer


In this problem, the compiler is checking all the if-else conditions one by one so that where the if a condition is satisfied, it compiles that line a
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe