003-002-009
Assignment Operator: Using Compound Assignment Operators
Easy
Problem Description
Assignment operator: Using Compound Assignment Operators
In this problem, you will create a program that calculates a game's final score by adding bonus points, subtracting a penalty, and applying a multiplier to an initial score, then displays the result to standard output.
Learning Objective: Understand how to write concise code using compound assignment operators (+=, -=, *=, /=)
Overview
Create a game score management system. Using compound assignment operators allows you to write "update variable value" operations more concisely.
Specifications
Receive the following values from standard input:
- Initial score (integer)
- Bonus points (integer)
- Penalty points (integer)
- Multiplier (integer)
Processing:
- Add bonus points to score (use +=)
- Subtract penalty points from score (use -=)
- Multiply score by multiplier (use *=)
Output the final score in format "Final Score: [score]".
Input Example
100
50
20
2
Output Format
Final Score: 260
Calculation Example
- Initial: 100
- Add bonus: 100 + 50 = 150
- Subtract penalty: 150 - 20 = 130
- Apply multiplier: 130 × 2 = 260
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up