003-001-013

Compound Assignment Operators

Medium

Problem Description

Compound Assignment Operators

In this problem, you will create a program that reads an initial value and four operands from standard input, applies compound assignment operators (+=, -=, *=, /=) in sequence, and displays the results to standard output.

Learning Objective: Understand how to use compound assignment operators like +=, -=, *=, /=

Overview

Use Scanner to read input values and compound assignment operators to efficiently update variable values.

Input Specification

initialValue
addValue (used for +=)
subValue (used for -=)
mulValue (used for *=)
divValue (used for /=)

Output Format

Initial: initialValue
After += addValue: result
After -= subValue: result
After *= mulValue: result
After /= divValue: result

Input/Output Example

Input:

100
50
30
2
4

Output:

Initial: 100
After += 50: 150
After -= 30: 120
After *= 2: 240
After /= 4: 60

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