Program 1: You need to ask users to enter ten words and scan it. You will store
ID: 3860529 • Letter: P
Question
Program 1: You need to ask users to enter ten words and scan it. You will store all the words into ArrayList. Once all the words are
stored then you will sort all the words and display it onto the screen.
Program 2: You need to ask users to input number of years experience and add following strings depending upon a number of years.
NumberOfYears < 5: Beginner
NumberOfYears < 10 and > 5: Mid
NumberOfYears <15 and > 10: Experienced
NumberOfYears <20 and > 15: Executive
You will then stored the entire output 4+Beginner on the stack. You need to use Push method to insert at least four records and then print stack output on the screen.
Program 3: You will use the scanner class and ask users following things.
- Age
- Name
- Address
You will then create a queue and store all the information. You need to save at least three records and then print the size of the queue.
Explanation / Answer
NOTE: I have finished the program.1 and due to some program errors i was not able to provide program.2 and program.3 which i will provide within another 24 hours.
Program.1 :
Code:
import java.util.*;
public class HelloWorld{
public static void main(String []args){
Scanner sc = new Scanner(System.in);
ArrayList<String> wordList = new ArrayList<String>();
System.out.println("Enter ten words? ");
for(int i = 0; i < 10; i++){
String str = sc.nextLine();
wordList.add(str);
}
Collections.sort(wordList);
System.out.println("After sorting the words");
for(String each_word: wordList)
System.out.println(each_word);
}
}
Code output link:
https://pasteboard.co/GCFfwRE.png
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.