1. Generate 20 random numbers between 0 to 100 and assign them to an array of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
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 ... View the full answer
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these programming questions
-
You are asked to develop a Floppy Disk program that allows users to access a floppy disk locally mounted on a computer. You are expected to use C programming language. In your program, all file I/O...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
Requirement 1 Two contribution format statements: current and proposed based on business decision. Requirement 2 For each option current and proposed business decision) calculate the following: a....
-
At Precision Custom Molds, manufacturing overhead was estimated to be $20,000,000 at the start of the year and direct labor hours were estimated to be 200,000. Overhead is applied to jobs using a...
-
A major pharmaceutical manufacturer is facing a difficult decision concerning one of its hearing enhancement products. The product has been on the market less than two years, and reports have...
-
In 2001, the City of New York and the Dormitory Authority of the State of New York (DASNY) entered into an agreement to build a forensic biology laboratory in Manhattan. Per the agreement, DASNY...
-
Clark Products makes pizza ovens for commercial use. Michael Clark, CEO, is contemplating producing smaller ovens for use in high school and college kitchens. The activities necessary to build an...
-
From the following ER diagram a) Translate it into a relational model b) Normalize it into BCNF (if possible) user id email name item_id description AuctionStartDate password phone_no age Browses 1...
-
The irreversible, first-order reaction of gaseous A B occurs in spherical catalyst pellets with a radius of 2 mm. For this problem, the molecular diffusivity of A is 1.2 X 10 1 cm 2 /s and the...
-
Suppose that wavelike quasiparticles, having the dispersion relation = Akn exist in a solid and yield a specific heat when they are excited as thermal motion. show that the heat capacity is...
-
Current Attempt in Progress Sheffield Company's condensed income statement is presented below: Revenues $915,000 Expenses Cost of goods sold $400,000 Operating and administrative expenses 297,000...
-
Explain how transformational leadership affects organizational structure and organizational culture with examples from the literature.
-
What is the complexity of the following tasks? 1) Finding the largest two elements in a queue of size n+3 using Nave search. 2) Remove the first item at the bottom of a stack data-structure of size...
-
Start by reviewing this case study in detail - https://cloud.google.com/customers/la-provence Based on the above case study address 3 primary questions - Assume you were the CDO at La Provence in...
-
Explain the following: (1) Force field analysis and (2) Content analysis. How are they different from each other and what will be your preferred method of analyzing data.
-
Briefly discuss the nature of Single entry and double entry system.
-
In Exercises find dy/dx by implicit differentiation. xy - y = x
-
By recent estimates, two-thirds of the people in the United States are overweight and about half of those are obese. This causes significant increases in illnesses such as diabetes and heart disease....
-
Create an art app similar to the Painter app so that allows you to draw shapes by clicking and dragging the mouse in a Canvas. Include options for: a) Selecting the shape to drawline, rectangle or...
-
In Fig. 17.24 , we implemented a stream pipeline that rolled a die 60,000,000 times using values produced by SecureRandom method ints. Use the same timing techniques you used in Exercise 17.25 to...
-
The quotation from Calvin Coolidge at the beginning of the chapter equates taxation to robbery. a. Is that a reasonable position to take? b. What alternatives to taxation could a country consider to...
-
If price moves from disequilibrium to equilibrium, what happens to the combination of producer and consumer surplus in the market?
-
Why does nearly every purchase you make provide you with consumer surplus?
Study smarter with the SolutionInn App