Evaluating Expressions that Contain if Statements
Need Help? Check out these resources!
Evaluating Expressions
|
Grab a Piece of Paper! |
Evaluate each expression. Verify your answer by running the code in the Java Playground. |
Practice 1: Shopping Cart Discount
- Predict the output of the expression.
- Verify your prediction is correct by running the code in the Java Playground.
- Identify possible values for
totalPurchaseand corresponding outputs that can be used to test the code is working as expected. - Modify the code to use these test values.
- Verify the corresponding outputs by running the code in the Java Playground.
Practice 2: Bank Account Withdrawal
- Predict the output of the expression.
- Verify your prediction is correct by running the code in the Java Playground.
- Identify possible values for
balanceandwithdrawalas well as the corresponding outputs that can be used to test the code is working as expected. - Modify the code to use these test values.
- Verify the corresponding outputs by running the code in the Java Playground.
Practice 3: Temperature Check
- Predict the output of the expression.
- Verify your prediction is correct by running the code in the Java Playground.
- Identify possible values for
temperatureas well as the corresponding outputs that can be used to test the code is working as expected. - Modify the code to use these test values.
- Verify the corresponding outputs by running the code in the Java Playground.
Practice 4: Library Membership Verification
- Predict the output of the expression.
- Verify your prediction is correct by running the code in the Java Playground.
- Identify possible values for
hasLibraryCardandhasPhotoIDas well as the corresponding outputs that can be used to test the code is working as expected. - Modify the code to use these test values.
- Verify the corresponding outputs by running the code in the Java Playground.
Practice 5: Library Membership Verification
- Predict the output of the expression.
- Verify your prediction is correct by running the code in the Java Playground.
- Identify possible values for
ageandparentalConsentas well as the corresponding outputs that can be used to test the code is working as expected. - Modify the code to use these test values.
- Verify the corresponding outputs by running the code in the Java Playground.
Practice 6: Vacation Approval
- Predict the output of the expression.
- Verify your prediction is correct by running the code in the Java Playground.
- Identify possible values for
isManageranddaysAvailableas well as the corresponding outputs that can be used to test the code is working as expected. - Modify the code to use these test values.
- Verify the corresponding outputs by running the code in the Java Playground.
Practice 7: Contest Participation
- Predict the output of the expression.
- Verify your prediction is correct by running the code in the Java Playground.
- Identify possible values for
ageandhasParentPermissionas well as the corresponding outputs that can be used to test the code is working as expected. - Modify the code to use these test values.
- Verify the corresponding outputs by running the code in the Java Playground.
Practice 8: Multi-level Discount Application
- Predict the output of the expression.
- Verify your prediction is correct by running the code in the Java Playground.
- Identify possible values for
totalPurchaseandisMemberas well as the corresponding outputs that can be used to test the code is working as expected. - Modify the code to use these test values.
- Verify the corresponding outputs by running the code in the Java Playground.
Practice 9: Exam Result Status
- Predict the output of the expression.
- Verify your prediction is correct by running the code in the Java Playground.
- Identify possible values for
scoreandattendedExamas well as the corresponding outputs that can be used to test the code is working as expected. - Modify the code to use these test values.
- Verify the corresponding outputs by running the code in the Java Playground.
Practice 10: Delivery Zone and Availability Check
- Predict the output of the expression.
- Verify your prediction is correct by running the code in the Java Playground.
- Identify possible values for
cityandslotsAvailableas well as the corresponding outputs that can be used to test the code is working as expected. - Modify the code to use these test values.
- Verify the corresponding outputs by running the code in the Java Playground.