Question: 8, write a program to calculate entire program instead of only a code segment. (8 pts) +and print out the result. Note: write the The

 8, write a program to calculate entire program instead of only

8, write a program to calculate entire program instead of only a code segment. (8 pts) +and print out the result. Note: write the The following Java code uses Scanner to obtain a number (about how many facebookPersons to create) from the user and save the number in variable numP. The code has two limitations: 1) it does not handle the situation when the user input is not a number; 2) it does not have logic to check if the entered number is too big or too small. Modify the code to fix the above problems when the user input is not a number, the program prints a not a number user to enter another number; when the entered number is smaller than 1 or greater than 5, the program prints a "invalid number" message and asks the user to enter another number. This continues until a correct number is entered 9. Bonus Problem (5pts) message and asks the Scanner userInput new Scanner (System. In) System.out.println("Enter the nunber of facebookpresons to be created: " int numP-O numP userInput.nextInt )2 Note: the Scanners nextint) throws an InputMismatchException if the input is not a number Provide your answer below

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!