Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. (4 points; 2 points each) Suppose we have the method defined below: public static int percentOutOfRange Exclusive (Scanner keyboard, String prompt, int low,
1. (4 points; 2 points each) Suppose we have the method defined below: public static int percentOutOfRange Exclusive (Scanner keyboard, String prompt, int low, int high, int count) { int outOfRange int reps = 0; = 0; // Counter controlled loop while (reps < count) { // Read input System.out.println(prompt); int entry = keyboard.nextInt(); keyboard.nextLine(); // Increment outOfRange if the entry is not between low and high // exclusive if (entry low || entry > high) { outOfRange = outOfRange + 1; } reps = reps + 1; } } return (int) Math.round(outOfRange * 100.0/ count); a) Write a complete main program that calls the method above to print to the console the percent of 50 values entered at the keyboard that are not between 1 and 10 (exclusive). Because the Scanner is a parameter, it will need to be declared and constructed in the main program. Write your own prompt. b) Write a complete main program that calls the method above to print to the console the percent of 10000 values entered at the keyboard that are not between -1000 and 1000 (exclusive). Because the Scanner is a parameter, it will need to be declared and constructed in the main program. Write your own prompt. 2. (5 points; 1 point each line) In the percentOutOfRange Exclusive method from problem 1, show all identifiers that fall into each category. Some lines may be blank. Parameter(s) Arguments(s) Local variables Return type Method name
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started