Question
In Java, 3 things need to be changed 1. Array size should be less than 100 2. in the input, first enter the name. when
In Java,
3 things need to be changed
1. Array size should be less than 100
2. in the input, first enter the name. when entering the "END", the program ends the first loop, and then you can enter the Gifts. After entering a few gifts, enter "END" again. the program should end and print the NAMES, GIFTS as sort.
3. When printing the output, should only print the name, gift. when they do not have the same first letter, only print the name. In the end, print all gifts which not show before.
Scanner sc = new Scanner(System.in); int totalNames = 100; int totalGifts = 100; String[] Names = new String [totalNames]; // Array for names String[] Gifts = new String [totalGifts]; // Array for gifts //while (!sc.equals("END")) { for(int o = 0; o < Names.length;o++) // for loop for input the Names { System.out.print("Enter the Names:"); Names[o] = sc.nextLine(); //break; } // } // while(sc.equals("END"));{ for(int p = 0; p < Gifts.length;p++) // for loop for input the Gifts { System.out.print("Enter the gifts:"); Gifts[p] = sc.nextLine(); //break; } // } int num = Names.length; for(int j=1; j
} }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started