Question

write the jave code for the following

1 2 7 B9 4 5 10 11 12 15 13 16 23 24 14 22 17 25 26 18 19 21 20 INRerscrorTro zo Question 11 15 points Save Answer Suppose we

0 0
Add a comment Improve this question Transcribed image text
Answer #1

int count = 0;

for(int i =0 ; i <numbers.length ; ++i ) {
if( numbers [i] > numEntered )
++count;
}


System.out.println("Number of elements in array larger than " + numEntered + " is " + count );

Thanks, PLEASE COMMENT if there is any concern.

Add a comment
Answer #2

CODE IN JAVA:

DemoArray.java file:

import java.util.Scanner;
public class DemoArray {
   public static void main(String args[]) {
       int[] numbers = {23,2,32,13,43,67,102,19,5,88};
       System.out.print("please enter a number: ");
       Scanner console = new Scanner(System.in);
       int numEntered = console.nextInt();
       int count = 0 ;
       for(int val : numbers) {
           if(val>numEntered)
               count += 1 ;
       }
       System.out.println("The number of elements larger than entered number is in the array is: "+count);
   }
}

OUTPUT:

Declaration Console Problems Javadoc Coverage <terminated> DemoArray [Java Application] C\Program Files\Java\jre1.8.0_171\bin

Add a comment
Know the answer?
Add Answer to:
write the jave code for the following 1 2 7 B9 4 5 10 11 12...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Ch. 09: Exclusive find in Array (Arrays, conditional, counter) Write a method that will receive an...

    Ch. 09: Exclusive find in Array (Arrays, conditional, counter) Write a method that will receive an array of integers and an integer value as a parameter. The integer value received as the second parameter will be searched within the Array received as the other parameter. The method will return true if the value appears only once in the Array. Use the "documentation shown in the program as a guide". As an example, if the array received was the sequence of...

  • Computer Science - Java Explain the code step by step (in detailed order). Also explain what...

    Computer Science - Java Explain the code step by step (in detailed order). Also explain what the program required. Thanks 7 import java.io.File; 8 import java.util.Scanner; 9 import java.util.Arrays; 10 import java.io.FileNotFoundException; 12 public class insertionSort 13 14 public static void insertionSort (double array]) 15 int n -array.length; for (int j-1; j < n; j++) 17 18 19 20 21 double key - array[j]; int i-_1 while ( (i > -1) && ( array [i] > key array [i+1] -...

  • Assume the following declarations have been made in main(): int howmany; Scanner kb = new Scanner(System.in);...

    Assume the following declarations have been made in main(): int howmany; Scanner kb = new Scanner(System.in); Random r = new Random(); Write code to do the following: Use a while loop to prompt the user for how many numbers are to be entered. If the user does not enter a positive number (a number greater than 0), display a message saying the number must be positive and to try again. Store this value in the howmany variable. Declare an integer...

  • please show the code in java,thanks 5. Perfect Numbers Version 2: Write a program which computes...

    please show the code in java,thanks 5. Perfect Numbers Version 2: Write a program which computes perfect numbers according the following algorithm: for each prime, p: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53 if 2P 1 s prime (2P (2 is perfect: print both p and (2P 1)(2) Note: You will need to use the Biglnteger clas for thist

  • Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges...

    Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges two arrays of positive integers and removes any duplicate entries. Your program will first ask for a valid length which must be an integer which is 10 or greater. The program should continue to ask until a valid length is entered. The program will then create two arrays of the length entered, fill these with random integers between 1 and 100 inclusive, and print...

  • The following code is a Java code for insertion sort. I would like this code to...

    The following code is a Java code for insertion sort. I would like this code to be modified by not allowing more than 10 numbers of integer elements (if the user enters 11 or a higher number, an error should appear) and also finding the range of the elements after sorting. /* * Java Program to Implement Insertion Sort */ import java.util.Scanner; /* Class InsertionSort */ public class InsertionSortTwo { /* Insertion Sort function */ public static void sort( int...

  • Assignment 11 – Exceptions, Text Input/Output - Random Numbers Revised 9/2019 Chapter 12 discusses Exception Handling...

    Assignment 11 – Exceptions, Text Input/Output - Random Numbers Revised 9/2019 Chapter 12 discusses Exception Handling and Input/Output. Using try/catch/finally statement to handle exceptions, or declare/throw an exception as needed, create the following program: Create an array of 25 random numbers between 0 & 250 formatted to a field width of 10 & 4 decimal places (%10.4f). Use the formula Math.random() * 250. Display the array of random numbers on the console and also write to a file. Prompt the...

  • JAVA

    Write a Java class (program) which inputs a simple integer and outputs a list of values from the input variable down to 0 (not including 0). You should only show every other value in the output, starting with the input value. You must use a for loop.For example, if the input is 23, the output should be:The input value was 2323 21191715131197531Code given:import java.util.Scanner;/**  * This program counts down from the input number down to (but not including)   * 0, skipping...

  • help fixing this code in JAVA SIC 7 19 11 12 src eclipse-workspace - doublesalary2/src/module-info.java -...

    help fixing this code in JAVA SIC 7 19 11 12 src eclipse-workspace - doublesalary2/src/module-info.java - Eclipse IDE HG2GP Package Explorer X B J "module-info.java X J module-info.java Outline X Assigment 1 @ 1 module doublssalary21 bill import java.util.Scanner; doublosalary2 doublasalary N 4 public class DoubleSalary I DoubleSalary > JRE System Library (JavaSE-14) M 5 public static void main(String[] args) { @ main(Stringni : void 6 Scanner sc = new Scanner(System.in); doublasalary2 System.out.print("Enter number of days: "); 8 ► JRE...

  • The ExceptionLab class provided: – Creates an array of 100 elements and fills it with random...

    The ExceptionLab class provided: – Creates an array of 100 elements and fills it with random numbers from 1 to 100. – It asks the user for an index value between 0 and 99. – Prints the element at that position. – If a number > 99 is entered by the user, the class will abort with an ArrayIndexOutOfBoundsException • Modify the ExceptionLab: – Add a try-catch clause which intercepts the ArrayIndexOutOfBounds and prints the message: Index value cannot be...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT