1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kkurt [141]
3 years ago
10

Implement a function named largerThanN that accepts three arguments: an array of type int, the size of the array of type int and

an int number n. The function should display all of the numbers in the array that are greater than the number n. in the main() function create an array named numbers containing 10 integers : 30,20,50,2,-1,44,3,12,90,32 Ask the user to enter a number. Call the the function largerThanN and pass the array , the size and the number that user entered.
Computers and Technology
1 answer:
levacccp [35]3 years ago
6 0

Answer:

import java.util.Scanner;

public class NewArray {

//Main Method begins here

   public static void main(String[] args) {

   int [] numbers = {30,20,50,2,-1,44,3,12,90,32}; //The given array

   Scanner in = new Scanner(System.in);

       System.out.println("enter a number");

       int n = in.nextInt(); //Receive the number from the user

       //Calling the method largerThanN

       largerThanN(numbers, numbers.length,n);

   }

//The method largerThanN begins here

   public static void largerThanN(int []intArray, int arraySize, int n){

       for(int i = 0; i < intArray.length; i++){

           if(intArray[i] > n){

               System.out.println(intArray[i]);

           }

       }

   }

}

Explanation:

Uisng the Java prograamming language the solution is provided above.

Please see the comments within the code for detailed explanation

The key logic within the method largerThanN () is using a for loop to iterate the entire array. Within the for loop use an if statement to compare each element with the the number n entered by the user

You might be interested in
Write a method named showChar. The method should accept two arguments: a reference to a String object and an integer. The intege
matrenka [14]

A complete program with the method ShowCar:

import java.util.Scanner; // header file

public class ShowChar

{

public static void main(String[] args)

{

String lnOfText;

int i;

Scanner input = new Scanner(System.in);

System.out.print("Enter a line of text:");

lnOfText = input.nextLine();

System.out.print(" Enter your index: ");

i = input.nextInt();

show_Char(lnOfText,i);

}

public static void show_Char(String str_a, int i)

{

System.out.print(str_a.charAt(i));

}

}

In this program, both the inputs ie. a sentence or line of text as well as the index position is obtained. A method is written to find the string at that particular position. Finally the method prints that character at the particular index.

5 0
3 years ago
Gas giants have rings and satellites.
user100 [1]
Gas giants DO have rings and satellites.
It's true.
6 0
3 years ago
Read 2 more answers
give an example of both a negative and positive coping mechanism you could use to deal with this stress?
Andru [333]

Answer:

Negative coping mechanism deals with Substance dependence, abuse, and use; anger, violent mentality, risky mentality, dangerous mentality, reminders such as trauma, etc.

The positive coping mechanism can be like an attempt to transform or change the issue into something other than that. As an example, it can be like converting a stressful situation into a positive situation.

Explanation:

Please check the answer section.

4 0
3 years ago
Question 5 a remote access server is typically implemented on a server class operating system, such as windows server 2008 r2 ru
Reika [66]
Answer: <span>Routing & </span>Remote Access<span> (RRAS)</span>
7 0
3 years ago
Which of the following reflects Moore's law? a. The doubling of computer chip performance per dollar every two years. b. A compa
Aleonysh [2.5K]

Answer:

c. A company's ability to acquire small amounts of capital for spending on innovative ideas every two years.

Explanation:

4 0
3 years ago
Other questions:
  • Think of a game you are familiar with and identify at least three team responsibilities which were required to make the game, on
    5·1 answer
  • Why was Windows 1.0 considered an operating environment rather than an operating system?
    10·2 answers
  • This is a broad category of applications and technologies for gathering, storing, analyzing, and providing access to data to hel
    12·1 answer
  • In which file format is image data compiled into a binary file? TIFF SVG CGM BMP
    11·1 answer
  • Structure for forloop?
    10·1 answer
  • 3. What term refers to the physical locations of elements in relation to each other?
    10·2 answers
  • A new product was introduced in 2003, which functions as both an identification device and a medium of communication. It uses in
    8·1 answer
  • Describe a way that you can envision using the power of the computer through
    13·1 answer
  • I'm not sure how to do these. By the way, it has to be python.
    13·1 answer
  • Search the Web for three different employee hiring and termination policies. Review each and look carefully for inconsistencies.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!