Question

Write a java program that allows the user to input 20 double type numbers to an...

Write a java program that allows the user to input 20 double type numbers to an array and then output the largest (max) number.

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


import java.util.Scanner;
//Java program to find the largest number
public class LargestDouble {
   //Main function where the execution is begins
   public static void main(String arg[]) {
       System.out.println("Enter 20 Numbers");
       //Code to read the values
       Scanner in = new Scanner(System.in);
       double arr[] = new double[20];
       for(int i=0; i<20;i++) {
           arr[i]=in.nextDouble();//Reading data from user and storing in to array
       }
       //Code to find the larget value
       double max=arr[0];
       for(int i=1; i<20;i++) {
           if(arr[i]>max) {
               max=arr[i];
           }
          
       }
       //Displaying the max values
       System.out.print("The maximum value is ");
       System.out.println(max);
   }
      
  
}
Output

Kindly let me know if any mistakes

Add a comment
Know the answer?
Add Answer to:
Write a java program that allows the user to input 20 double type numbers to an...
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
  • Please write a java program that takes in user input of various numbers as a type...

    Please write a java program that takes in user input of various numbers as a type string, prints the sum of all numbers entered, and prints the smallest and largest numbers. Arrays are optional as they have not been covered by my professor yet. Thank you

  • Write a java program that will print if n numbers that the user will input are...

    Write a java program that will print if n numbers that the user will input are or not within a range of numbers. For that, your program needs to ask first for an integer number called N that will represent the number of times that will ask for other integer numbers. Right after, it should ask for two numbers that will represent the Min and Max for a range. Lastly. it will iterate N number times asking for an integer...

  • Write a program that will take input from a file of numbers of type double and...

    Write a program that will take input from a file of numbers of type double and output the average of the numbers in the file to the screen. Output the file name and average. Allow the user to process multiple files in one run. Part A use an array to hold the values read from the file modify your average function so that it receives an array as input parameter, averages values in an array and returns the average Part...

  • Write a Java program which allows the user to perform simple tasks on a calculator. A...

    Write a Java program which allows the user to perform simple tasks on a calculator. A series of methods allows the user to select an operation to perform and then enter operands. The first method displays a menu, giving the user the choice of typing in any one of the following: +, -, *, /, or % representing the usual arithmetic operators (Each operation should be done on numbers negative(-) to positive(+), positive(+) to negative(-), negative(-) to negative(-), and positive(+)...

  • Write a java program that create a 2 dimensional array of type double of size 10...

    Write a java program that create a 2 dimensional array of type double of size 10 by 10. Fill the array with random numbers using a random number generator. Print the array contents. Write a java program that creates a file called data.txt that uses the PrintWriter class. Write the numbers 1 to 42 into the file. Close the file. Attach both files. Thank you in advance

  • write a program that gets a list of double numbers from user and output the largest...

    write a program that gets a list of double numbers from user and output the largest and smallest one by using array intro Computer science problem InFocus Name Cortlyn CUNYID 123 JseR jeno5678 Psswot C:)2315 Cs coubles User hoje56 7 Password Csla3u56 WR user and om CS I fall one wite tha apeatal holaces Cand vetun ae out Put

  • Write a JAVA program that has the user input two numbers and calls a method lesser...

    Write a JAVA program that has the user input two numbers and calls a method lesser that finds the smaller of the two numbers input.

  • 2. Write a program that reads N integer numbers of array from the user and then...

    2. Write a program that reads N integer numbers of array from the user and then displays the sum, max number and the numbers of the array use four subroutines ( Read_Array(), Calculate_Sum(), Find_Max() and Display_Array()). Here is sample output Please enter number of elements: 4 Please enter the required numbers: 50 100 150 20 The entered numbers are: 50 100 150 20 Sum is : 320 Max is 150 by Mpsi ,sum and max to call subroutine and retrieve...

  • In java, write a program that gets 10 integer numbers from the user using user input,...

    In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read.   Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. version1:  use a while loop. version2:  use a do-while loop. version 3:  use a for loop. For each version, use a loop to input 10 int numbers from the user...

  • Q1. Write a program in Java         a. Create 2 separate arrays, of user defined values,...

    Q1. Write a program in Java         a. Create 2 separate arrays, of user defined values, of same size         b. Add these 2 arrays. ........................................................................................................................... Q2. Write a program in java (using loop) input any10 numbers from user and store in an array. Check whether each of array element is positive, negative, zero, odd or even number. ............................................................................................................................ Q3. Write a program in Java to display first 10 natural numbers. Find the sum of only odd numbers. .............................................................................................................................. Q4....

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