Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribedimage text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

=+5. What is the prenatal development sequence?

Answered: 1 week ago

Question

Cmo afect la naturaleza diversa del grupo las acciones del comit?

Answered: 1 week ago