Question: Exercise 1: Modify the following program to fix syntax and logical errors. The program has to print the product and the sum of 3 integers.

 Exercise 1: Modify the following program to fix syntax and logicalerrors. The program has to print the product and the sum of3 integers. public class ThreeNumberPs { public static void main(String[] args) {

Exercise 1: Modify the following program to fix syntax and logical errors. The program has to print the product and the sum of 3 integers. public class ThreeNumberPs { public static void main(String[] args) { int number 1 = 2 int number2 = 3 int number3 = 4 int product = 0; int sum = 0; product = (number1 + Number2) + number3; System.out.print("The product is " + "product"); System.out.print("The sum is " + Sum); } The output has to be as the following: Output - JavaApplication2 (run) * run: D The product is 9 The sum is 24 BUILD SUCCESSFUL (total time: 0 seconds) I Exercise 2: Write a Java program to display the following shape. * *** * + + * * * * * * *** *** * * * * *** Exercise 3: Write a Java program to display the following shape. Exercise 4: Write a java program that calculates the doubles and squares of the numbers from 1 to 5 and prints the resulting values in a table format, as shown below. Num Double Square 1 2 3 4 5 1 4 6 8 10 9 16 25 Exercise 5: Write a java program to swap then display the values of two integer variables first and second. Your program should display the output as shown below. [Hint: Use a temporary variable to do the swap). Output D Debugger Console x Jasiepatoos frun) x run: BEFORE SWAP First - 10 Second - 40 AFTER SWAP First = 40 Second = 10 BUILD SUCCESSFUL (total time: 0 seconds)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!