Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Generate 20 random numbers between 0 to 100 and assign them to an array of 20 members. The program will then calculate the

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

1. Generate 20 random numbers between 0 to 100 and assign them to an array of 20 members. The program will then calculate the second biggest number & the average. The program will display all the 20 numbers, the second biggest number, and the average values. Note a. random numbers can be generated using the Random library. Read about the library [here] b. do not use sort() or any other standard Java function in finding the second biggest number. Create your steps/algorithm. Expected Result: Random numbers generated: 23 23 37 53 15 98 23 48 60 55 48 68 50 5 56 74 41 42 81 28 Second biggest number: 81 Average value: 46.40 2. Ask the user to enter a string consisting of ten (10) integer numbers separated by comma (, ). Then split the string into individual integer values. Next, add the numbers in pairs (5 pairs) and assign the addition result to an array of 5 integer members. Display the original numbers and the array on the screen. Note: to split a string of integer numbers, use the split() function. For details, read [here] Expected Result: Enter 10 numbers separated by comma 1,2,3,4,5,6,7,8,9,10 Individual numbers: 1 2 3 4 5 6 7 8 9 10 Array members: 3 7 11 15 19 3. Ask the user to enter ten (10) numbers separated by a comma. The program will identify duplicate numbers in the list and display them on the screen. Expected Result: Enter 10 numbers separated by comma 1,2,3,1,4,5,6,4,8,9 Duplicate numbers: 1, 4 4. Ask the user to enter 2 sets of 10 integer numbers, separated by a comma. Combine both numbers into an array variable. Next, remove all numbers that appear in both sets or duplicate numbers. Display all the unique numbers on the screen. Expected Result: Enter 10 numbers separated by comma 1,2,3,4,5,6,7,8,9,10 Enter 10 numbers separated by comma: 11,12,1,2,3,19,20,4,10,21 Unique numbers in array : 5, 6, 7, 8, 9, 11, 12, 19, 20, 21 5. Ask the user to enter 10 integer numbers, separated by a comma. The program will count the frequency of each number in the list and display it on the screen. Expected Result: Enter 10 numbers separated by comma 1,1,4,7,5,6,7,8,2,7 Frequence of members : 1 - 2 time 4 - 1 time 51 time 6 - 1 time 73 time 8 - 1 time 2 - 1 time 6. Ask the user to enter one (1) number at a time. If the number is bigger than 100, show an error message and ask the user to enter again. If the user enters 0, the input process will stop. The program will display all the numbers entered by the user, followed by lists of even and odd numbers. Expected Result: Please enter a number (1 to 100). Enter 0 to stop 10 Please enter a number (1 to 100). Enter 0 to stop : 51 Please enter a number (1 to 100). Enter to stop : 67 Please enter a number (1 to 100). Enter 0 to stop : 101 Sorry. Invalid number. Please enter again Please enter a number (1 to 100). Please enter a number (1 to 100). Please enter a number (1 to 100). Please enter a number (1 to 100). Please enter a number (1 to 100). Please enter a number (1 to 100). Please enter a number (1 to 100). Enter 0 to stop: 0 Output: Enter 0 to stop: 99 Enter 0 to stop : 88 Enter 0 to stop : 88 Enter 0 to stop : 79 Enter 0 to stop : 39 Enter to stop : 12 You entered : 10, 51, 67, 101, 99, 88, 88, 79, 39, 12 Even numbers: 10, 88, 88, 12 Odd numbers 51, 67, 101, 99, 79, 39 7. Ask the user to enter an integer number, and the program will display its factorial value. The user can try as many times as he likes. Expected Result: Please enter a number : 5 5! is 120 Try again? Press y or n: y Please enter a number : 10 10! Is 3628800 Try again? Press y or n: n Thank you. 8. 9. Ask the user to enter an integer number, N. The program will display a list of N Fibonacci numbers starting from 0. The user can try as many times as he likes. Note - What is a Fibonacci series? Please read about it [here] Expected Result: Please enter a number: 10 The first 10 Fibonacci number: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 Try again? Press y or n: y Please enter a number : 13 The first 10 Fibonacci number: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 Try again? Press y or n: n Thank you. A palindrome is a string that is spelled the same way forward and backward. Some examples of palindromes are: "radar", "able was i ere i saw elba" and, if you ignore blanks, "a man a plan a canal panama". Write a program that can identify if the text inserted by the user is a palindrome or not. The program should ignore spaces. Users can try the program as many times as he like. Expected Result: Please enter a string: kata k A palindrome Again? Press y or n: y Please enter a string: I love java Not a palindrome Again? Press y or n: n Thank you 10. (Airline Reservations System) A small airline has just purchased a computer for its new automated reservations system. The president has asked you to program the new system. You'll write a program to assign seats on each flight of the airline's only plane (capacity: 10 seats). Your program should display the following menu of alternatives: a. Please type 1 for "first-class" b. Please type 2 for "economy" If the person types 1, the program should assign a seat in the first-class section (seats 1-5). If the person types 2, your program should assign a seat in the economy section (seats 6-10). Your program should then print a boarding pass indicating the person's seat number and whether it is in the plane's first class or an economy section. Your program should, of course, never assign a seat that has already been assigned. When the first class section is full, your program should ask the person if it is acceptable to be placed in the economy section (and vice versa). If yes, then make the appropriate seat assignment. If no, then print the message "Next flight leaves in 3 hours." If all seats are booked, the program will stop taking new bookings. Expected Result: Welcome to SEGi Airlines - Ticket Booking System Press 1 for first-class Press 2 for economy Your selection ? 1 Your seat is in First Class - No 1 Press 1 for first-class seat Press 2 for economy seat Your selection ? 2 Your seat is in Economy Class - No 6 Press 1 for first-class seat Press 2 for economy seat Your selection ? 2 Your seat is in Economy Class - No 7 Press 1 for first-class seat Press 2 for economy seat Your selection ? 2 The economy class section is full. Would you like to sit in the first-class section (Y or N) ? N Next flight Leaves in 3 hours Press 1 for first-class seat Press 2 for economy seat Your selection ? 1 Your seat is in First Class - No 5 All seats for this flight is booked. Booking is now close.

Step by Step Solution

3.48 Rating (155 Votes )

There are 3 Steps involved in it

Step: 1

Here is a Java implementation for the 10 tasks provided java import javautil import javautilstreamCollectors import javautilstreamIntStream public class Main public static void mainString args Scanner ... 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

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Programming questions

Question

c. What type of degree does it offer?

Answered: 1 week ago

Question

Apply equivocality to an organization with which you are familiar.

Answered: 1 week ago