User Story
As a Salesforce Developer
I want to write a script that calculates the sum of two integers
So that I can log the result in the debug logs for verification during development.
Acceptance Criteria:
Input Variables:
The script must define two integer variables, num1
and num2
, with predefined values.
Example values:
num1 = 4
num2 = 8
Processing Logic:
The script must calculate the sum of the two integers using the +
operator.
The result must be stored in a variable named sum
.
Expected Outcome
The sum of 4 and 8 is 12
Solution
Integer num1 = 4;
Integer num2 = 8;
Integer sum = num1 + num2;
System.debug('The sum of ' + num1 + ' and ' + num2 + ' is ' + sum);
Explanation
In this example, we define two variables num1 and num2 and assign them the values 4 and 8, respectively.
We then create a third variable sum and assign it the value of num1 + num2, which calculates the sum of the two numbers.
Finally, we use the System.debug() method to print out a message that displays the values of the two numbers and their sum.
You can adjust the values of num1 and num2 to calculate the sum of any two numbers you want.
Video
Video does not exists.