# ask a user to enter 5 integer

gemini2
ask a user to enter 5 integer
1 Answer(s)      5 years and 8 months ago
Posted in : Java Beginners

make a program that enter 5 numbers then identify the largest and the smallest number

sample program 2 4 3 5 6 the smallest number: 2 the largest number: is 6

66

November 8, 2012 at 1:31 PM

Here is a code that accepts five numbers and find the largest and smallest number from the array of input numbers.

```import java.util.*;

public class FindLargestSmallestNumber {

public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("Enter 5 numbers: ");
int numbers[] = new int[5];
for(int i=0;i<numbers.length;i++){
numbers[i]=input.nextInt();
}
int smallest = numbers[0];
int largest = numbers[0];

for(int i=1; i< numbers.length; i++)
{
if(numbers[i] > largest)
largest = numbers[i];
else if (numbers[i] < smallest)
smallest = numbers[i];

}

System.out.println("Largest Number is : " + largest);
System.out.println("Smallest Number is : " + smallest);
}
}
```

ask a user to enter 5 integer
ask a user to enter 5 integer  make a program that enter 5 numbers then identify the largest and the smallest number sample program 2 4 3 5 6 the smallest number: 2 the largest number: is 6 66
accept integer from user
accept integer from user  Write an Java application that accepts 100 integer numbers from a user. The input should be in the range of 1-200. Error message needs to be displayed if user entered input which is not in this range
find largest num enter by user using loop method - Java Interview Questions
find largest num enter by user using loop method  hi..it's me again.. thanks for answering my question.. i wanna ask, if i wanna use loop... like this: for(int i=1; i<=5; i++){ System.out.println("Enter value
find the largest number enter by user - Java Interview Questions
find the largest number enter by user  sorry for not stating clearly my question. i want to know how to find the largest number enter by user...(fwriter); for(int i=1; i<=5; i++) { System.out.print("Enter a number
ask user how many numbers to be inputted and determine the sum and highest number using an array in java
ask user how many numbers to be inputted and determine the sum and highest number using an array in java  ask user how many numbers to be inputted and determine the sum and highest number using an array in java
Integer exception in java
the character input stream. The program will ask the user to enter the number , if the user enter the number other than integer it will gives an exception error. if the user enters integer it will display the number which the user have
I have a tex box. in that i want user should enter data in the format specified(for eg--a_b_c_d_e_)how to write code for it.
I have a tex box. in that i want user should enter data in the format specified(for eg--a_b_c_d_e_)how to write code for it.  I have a tex box. in that i want user should enter data in the format specified(for eg--abcde_)how
Change the user input to integer
Change the user input to integer   ... an integer value after the compilation of a program and force the JVM to ask... to enter a integer in a method or class using keyboard, then we have to use
Ask Questions with Options using Java In this section, we are going to ask five questions one after the other with four options to test the user. For this, we have stored 5 questions, answers with four options into a list. The list
Servlet Error Message based on user input
; which renders an input field to enter the name of the user. Here is the code...Servlet Error Message based on user input       In this example user is presented with a screen
Allow to Enter only numeric data.
Allow to Enter only numeric data.  hi....... I want to ask that in my project i have a textfield where user is going to enter the data so i want that the user should allow to enter only numeric data. I mean to say that if user
Java Reverse integer array
order. In the main method, we have allowed the user to enter numbers...]); } } } Output: Enter five array elements: 3 5 6 2 4 Array In Reverse Order: 4...Java Reverse integer array In this tutorial, you will learn how to reverse
The largest integer among the X number
will then ask the user if he/she wishes to exit the program or repeat the entire...The largest integer among the X number  Write an application program that prompts the user to key in a whole number X. The user is then prompted
Ask date difference  Hello, I have a problem about how to calculate... || curmonth == 5 || curmonth == 7 || curmonth == 8 || curmonth == 10 || cur_month... dates from the user and calculates the date difference in terms of days. import
Java coding for beginners
: This is just an example... Inputting and Echoing integer and string entered by user If the program prompt input from user their will be declaration of variables...; //num1 is a variable of integer type you can change it String word1; //string
Ask about looping in database  Good afternoon, I want to ask... = False | 1/2 | | 5 | A3 | If A1...=True,A2=True : code is the same data Rule and Heritage. I want to ask
integer to string
integer to string  i have to develop a program which convert integer into character from 1 to 10,000 if we input 1 then it give output 'one' n so on till 'ten thousand' kindly give me the codes plzplz sir........   Have
Ask java count  Good morning, I have a case where there are tables sumborrowbook fieldnya: codebook, bookname, and sumborrowbook . I want to make... | Java 1 | 10 | | b002 | beginner java | 5
Initializing Integer Variable issue?
Initializing Integer Variable issue?  My program is supposed to take... problem is my integer variables (number0 - number6). It is forcing me to initialize...; inputPhrase = JOptionPane.showInputDialog("Enter your phrase
Ask about java  Create a java program for add and remove the details of a person, which is not using by database, a simply java program. If possible, please wil it in switch case
Convert a String into an Integer Data
program we have prompted the user to enter the a String and then reads the data... Enter an integer number: 10 String: 10 Integer: 10... Convert a String into an Integer Data
it can be submitted by hitting ENTER
it can be submitted by hitting ENTER  How do I make a form so it can be submitted by hitting ENTER
Program to Ignore Space and Enter ?!
Program to Ignore Space and Enter ?!  Hi, dear friend i wont to write program to enter many statements, if i use Space and Enter in the Run Time must be delete the space and ignore the Enter ..for example if i entered