36.7k views
4 votes
Write a program in bluej to add 3 numbers and print the answer.​

1 Answer

0 votes

Answer:

Explanation:Sure, here is an example program in Java that adds 3 numbers and prints the answer using the BlueJ IDE:

java: ```

public class AddThreeNumbers {

public static void main(String[] args) {

int num1 = 10;

int num2 = 15;

int num3 = 20;

int sum = num1 + num2 + num3;

System.out.println("The sum of the three numbers is: " + sum);

}

} ```

This program declares three integer variables, assigns them the values 10, 15, and 20 respectively, adds them together, and stores the result in the variable sum. Then, it prints out the result using 'System.out.println()'.

You can replace the values of num1, num2, and num3 with whatever numbers you want to add.

User Liyakat
by
8.0k points