Question

Please code in java and add code... in an array containing 10 numbers, how to find...

Please code in java and add code... in an array containing 10 numbers, how to find the maximum and minimum values?

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

import java.io.*;
class MaxandMin
{
public static void main(String args[])
{
int arr[]=new int[10];
int min,max;
Console con=System.console();
System.out.println("Enter 10 intgers ");
for(int i=0;i<10;i++)
arr[i]=Integer.parseInt(con.readLine());
max=0;
for(int i=0;i<10;i++)
{
if(arr[i]>max)
{
max=arr[i];
}}
min=arr[0];
for(int i=0;i<10;i++)
{
if(arr[i]<min)
{
min=arr[i];
}}
System.out.print("Min is "+ min + "max is "+ max );
}}

Add a comment
Know the answer?
Add Answer to:
Please code in java and add code... in an array containing 10 numbers, how to find...
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
  • USE JAVA Using recursion, find the largest element in an array. Skeleton code is provided. Please...

    USE JAVA Using recursion, find the largest element in an array. Skeleton code is provided. Please do not change the DataSetDemo code. Hint: Find the largest element in the subset containing all but the last element. Then compare that maximum to the value of the last element. Skeleton Code: DataSet: /** Computes the maximum of a set of data values. */ public class DataSet { private int[] values; private int first; private int last; /** Constructs a DataSet object. @param...

  • JAVA / please add comments Write code for a method named loadDatagrams() that returns an array...

    JAVA / please add comments Write code for a method named loadDatagrams() that returns an array of type Datagram. The method will read from the filepath C:/folder/grams.dgf and the file contains an array of type Datagram ( you may assume that the class definition is visible to the method) Remember to include appropriate exception handling

  • java pseudocode and source code help? Write a program that uses an array of high temperatures...

    java pseudocode and source code help? Write a program that uses an array of high temperatures for your hometown from last week (Sunday - Saturday). Write methods to calculate and return the lowest high temperature (minimum) and a method to calculate and return the highest high temperature (maximum) in the array. You must write YOUR ORIGINAL methods for minimum and maximum. You MAY NOT use Math class methods or other library methods. Write an additional method that accepts the array...

  • JAVA Code: Complete the method, sumOdds(), below. The method takes in an array of integers, numbers,...

    JAVA Code: Complete the method, sumOdds(), below. The method takes in an array of integers, numbers, and returns the sum of all the odd numbers in the array. The method should return 0 if the array contains no odd numbers. For example, if the given array is [12, 10, 5, 8, 13, 9] then the method should return 27 (5+13+9=27). Starter Code: public class Odds { public static int sumOdds(int[] numbers) { //TODO: complete this method    } }

  • Write code to create a two-dimensional array named numbers containing 500 random numbers from 1 to...

    Write code to create a two-dimensional array named numbers containing 500 random numbers from 1 to 1000 inclusive. The array has 50 rows. Then walk through the array and output the random numbers 10 to a line. Format the numbers in right-aligned columns. Use the command prompt window for output. Note: do NOT create a class or main.

  • Java - how to get the minimum distance between array list elements? Code.

    Java - how to get the minimum distance between array list elements? Code.

  • 4. Write a program that finds the smallest element in a one-dimensional array containing 20 integer...

    4. Write a program that finds the smallest element in a one-dimensional array containing 20 integer values in the range 0 to N Hint: Consider following fragment of code Program in C language: for(c=0;c<size;c++) {     if(array[c] < minimum)     {         minimum = array[c];         location = c;     } } this c code is not running and missing some code . please add the missing code so when i paste it will run and provide flowchart

  • Please complete this code for java Lab Write a program as follows: Create an array with...

    Please complete this code for java Lab Write a program as follows: Create an array with 10 elements. The array should contain numbers generated randomly between 1 and 100 Ask the user to enter any number - Search the array to see if the user entered number is in the array If the user-entered number is in the array, print a 'match found' message. Also print at which index the match was found, else print a 'match not found' message...

  • Please do in java as simply as possible with code available for copy and comments. Provide...

    Please do in java as simply as possible with code available for copy and comments. Provide screenshots of code and how your incorporating the .txt file with the code. Write a program that reads in temperatures from the text file temps.txt (file given in the assignment). Write the minimum temperature, maximum temperature and the new array (temperatures plus 10) to a new file. The temperatures in file are: 83 87 81 88 90 92 95

  • Using JAVA, write an application that uses an Array of 30 Numbers (random integers from 1...

    Using JAVA, write an application that uses an Array of 30 Numbers (random integers from 1 - 100) and returns the maximum number, minimum number, average of all numbers, and prints a Bar Chart to show the number distribution (1-9, 10-19,20-29, …80-89, 90-100). Note; maximum number, minimum number, average number, and the Bar Chart must use implemented as separate methods in a separate class. Method call should pass an array as an argument. Methods should accept an array as an...

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