Answer to Question #284449 in Java | JSP | JSF for Millennium

Question #284449

Write a program to create two SDA to store 15 numbers each. Then create another array to store their sum. Then display values of three arrays in three different consecutive columns.

For example:

10   +    7   =  17

18   +   30  =  48

Where first column represents first array, second column represents second array and third column represents values of third array.


1
Expert's answer
2022-01-03T09:05:54-0500
import java.util.Scanner;


public class App {


	/**
	 * The start point of the program
	 * 
	 * @param args
	 * 
	 */
	public static void main(String[] args) {
		Scanner keyBoard = new Scanner(System.in);
		int numbers1[] = new int[15];
		int numbers2[] = new int[15];
		int sum[] = new int[15];
		System.out.println("Enter the numbers for the first array:");
		for (int i = 0; i < 15; i++) {
			System.out.print("Enter the number " + (i + 1) + ": ");
			numbers1[i] = keyBoard.nextInt();
		}
		System.out.println("\nEnter the numbers for the second array:");
		for (int i = 0; i < 15; i++) {
			System.out.print("Enter the number " + (i + 1) + ": ");
			numbers2[i] = keyBoard.nextInt();
		}
		for (int i = 0; i < 15; i++) {
			sum[i] = numbers1[i] + numbers2[i];
		}
		System.out.println("");
		for (int i = 0; i < 15; i++) {
			System.out.printf("%-5d +     %-5d =     %-5d\n", numbers1[i], numbers2[i], sum[i]);
		}


		keyBoard.close();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog