I want toprogram that if I choose\"1\" then ask the user to load the value at in
ID: 3610307 • Letter: I
Question
I want toprogram that
if I choose"1" then ask the user to load the value at index 0-9 of the "A"aray
and if ichoose "2" add all the elements of "A" array...
import java.io.*;
import java.util.Scanner;
public class assign
{
public static void main(String[] args)
{
{
System.out.println("*********************************************************");
System.out.println("* ArrayMenu *");
System.out.println("* *");
System.out.print ("* 1. Load the values in ");
System.out.print (""");
System.out.print ("A");
System.out.print (""");
System.out.print (" array");
System.out.println(" *");
System.out.print("* 2. Add all th elements of");
System.out.print (" "");
System.out.print ("A");
System.out.print (""");
System.out.print (" array");
System.out.println(" *");
System.out.print("* 3. Find maximum value in ");
System.out.print (" "");
System.out.print ("A");
System.out.print (""");
System.out.print (" array");
System.out.println(" *");
System.out.print("* 4. Find munimum value in ");
System.out.print (" "");
System.out.print ("A");
System.out.print (""");
System.out.print (" array");
System.out.println(" *");
System.out.print("* 5. Transpose");
System.out.print (" "");
System.out.print ("A");
System.out.print (""");
System.out.print (" array to");
System.out.print (" "");
System.out.print ("B");
System.out.print (""");
System.out.print (" array");
System.out.println(" *");
System.out.print("* 6. Display contents of ");
System.out.print (" "");
System.out.print ("A");
System.out.print (""");
System.out.print (" - Original Array");
System.out.println(" *");
System.out.print("* 7. Display contents of ");
System.out.print (" "");
System.out.print ("B");
System.out.print (""");
System.out.print (" - Transpose Array");
System.out.println(" *");
System.out.println("* 8. Exit *");
System.out.println("* *");
System.out.println("*********************************************************");
System.out.println("Select the menu options(1~8): ");
int option ;
Scanner keyboard = new Scanner(System.in);
option = keyboard.nextInt();
if (option ==1)
//{
int digit = 10;
int[] value = new int[digit];
Scanner Keyboard = new Scanner(System.in);
System.out.print("Please enter the value at index 1: ");
value[0] = keyboard.nextInt();
System.out.print("Please enter the value at index 2: ");
value[1] = keyboard.nextInt();
System.out.print("Please enter the value at index 3: ");
value[2] = keyboard.nextInt();
System.out.print("Please enter the value at index 4: ");
value[3] = keyboard.nextInt();
System.out.print("Please enter the value at index 5: ");
value[4] = keyboard.nextInt();
System.out.print("Please enter the value at index 6: ");
value[5] = keyboard.nextInt();
System.out.print("Please enter the value at index 7: ");
value[6] = keyboard.nextInt();
System.out.print("Please enter the value at index 8: ");
value[7] = keyboard.nextInt();
System.out.print("Please enter the value at index 9: ");
value[8] = keyboard.nextInt();
System.out.print("Please enter the value at index 10: ");
value[9] = keyboard.nextInt();
System.exit(0);
}
}
Explanation / Answer
please rate - thanks all fixed message me if any questions why did you do the menu like you did, and not like this ("didn't copy/paste well - spacing at end needs to be fixed) much easier to understand System.out.println("*********************************************************"); System.out.println("* ArrayMenu *"); System.out.println("* *"); System.out.println("* 1. Load the values in "A"array *"); System.out.println("* 2. Add all th elements of "A"array *"); System.out.println("* 3. Find maximum value in "A"array *"); System.out.println("* 4. Find minimum value in "A"array *"); System.out.println("* 5. Transpose "A" array to"B"array *"); System.out.println("* 6. Display contents of "A" - Original array *"); System.out.println("* 7. Display contents of "B" - Transpose array *"); System.out.println("* 8. Exit *"); System.out.println("* *"); System.out.println("*********************************************************");
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.