Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

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_2

Step: 3

blur-text-image_3

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

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

How does selection differ from recruitment ?

Answered: 1 week ago

Question

13-6 How will MIS help my career?

Answered: 1 week ago