Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

can someone help me to find answer of this question please? 5. The following pro

ID: 668829 • Letter: C

Question

can someone help me to find answer of this question please?

5. The following program is supposed to get 10 numbers from the user and display a total of how many ofthose numbers are between 10 and 20 (inclusive). So·ifthe user enters 4. 3. 20. 1. 10. 20. 116, 21. 17, the program should display that 5 of those numbers were in the correct range. This program nill compile, but when we run it, we will not get the desired results. What is wrong in this program? How will that cffect the results? How do we fir the program? Please be specific. (There are several problems -please list them all.) import java.util.*; public class Examl { public static void main (String[] args) Scanner s = new Scanner (System.in) ; int count = 1; for (int i = 0; i

Explanation / Answer

package mani;

import java.util.*;

public class Exam1{
  
//dont forget 21 doesnot lie between 10 and 20 so only 4  
public static void main(String[] args){
Scanner s=new Scanner(System.in);
int count=0;//start the count with zero
for(int i=0;i<10;i++){//only 10 numbers so no equal to
   System.out.print("Enter number: ");
   int num=Integer.parseInt(s.nextLine());
   if(num<=20 && num>10){//between 10 and 20 including 20 so the condition
               count=count+1;//add one to count number of numbers in 10 and 20
   }else{
       continue;//not break as it exits the loop so use continue
   }
}
System.out.println(count +" were between 10 and 20");
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote