find the largest number enter by user

find the largest number enter by user

View Answers

January 30, 2009 at 10:52 PM

Hi rayda

I got it your query, i am sending solved code here you can implement it in your code easily...


import java.util.Scanner;

public class Input{
public static void main(String[] args) {
String name;
int age;
Scanner in = new Scanner(System.in);

System.out.println("Enter Name: ");
name = in.nextLine();

System.out.println("Enter Age: ");
age=in.nextInt();

in.close();

System.out.println("Name :"+name);
System.out.println("Age :"+age);
}
}

Thanks...

January 31, 2009 at 5:26 AM

Hi rayda
This is your code, which has solved...

import java.io.*;
import java.util.Scanner;

public class ReadNumber{
public static void main(String[]args) throws IOException{
int num,max,min;
String filename;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter the filename: ");
filename=keyboard.nextLine();
FileWriter fwriter=new FileWriter(filename);
PrintWriter outputFile=new PrintWriter(fwriter);

int a, b, c, d, e;
Scanner in = new Scanner(System.in);

System.out.println("Enter first value: ");
a=in.nextInt();
System.out.println("Enter second value: ");
b=in.nextInt();
System.out.println("Enter third value: ");
c=in.nextInt();
System.out.println("Enter four value: ");
d=in.nextInt();
System.out.println("Enter five value: ");
e=in.nextInt();

System.out.println(a +" || "+ b +" || "+ c +" || "+ d +" || "+ e);

int arr[] = {a, b, c, d, e};
max = arr[0];
min = arr[0];

for(int j=0; j<5; j++){
if(max < arr[j]){
max = arr[j];
}else if(min > arr[j]){
min = arr[j];
}
}
System.out.print("\nGreatest Number: "+ max);
System.out.print("\nSmallest Number: "+ min);

//in.close();

for(int i=1; i<=5; i++){
System.out.print("\nEnter a number: ");
num=keyboard.nextInt();
outputFile.println(num);
keyboard.nextLine();
}
outputFile.close();
int sum;
String str;
double average;
FileReader freader=new FileReader(filename);
BufferedReader inputFile=new BufferedReader(freader);
sum=0;
str=inputFile.readLine();

while(str!=null){
sum=sum+Integer.parseInt(str);
str=inputFile.readLine();
}
inputFile.close();
System.out.println("The sum is: "+sum);
average=sum / 5.0;
System.out.println("the average is: "+average);
}
}
Thanks...









Related Tutorials/Questions & Answers:
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
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...(); System.out.println("Enter five value: "); e=in.nextInt(); is it possible to find the largest number?.. thanks again..  Hi You can implement it in loop
Advertisements
Find Second Largest Number from an Array
Find Second Largest Number from an Array This section illustrates you how to find the second largest number from an array. For this purpose, we have allowed the user to enter the array elements of their choice and determine the largest
how to find largest number? - Java Interview Questions
want to find the greater number which user enter on the console? Thanks...how to find largest number?  this is my java coding: import...); } } i don't know how to add code to find the largest number.. please help
USE ARRAY TO FIND THE LARGEST NUMBER AND OCCURRENCE
USE ARRAY TO FIND THE LARGEST NUMBER AND OCCURRENCE  i have some... it is: write a program that reads 10 numbers from the keyboard. find the largest number and count the occurrence of the largest number number entered from the keyboard
find largest value
recently input by the user. c. largest: The largest number found so far.   Java Find Largest Number import java.util.*; class FindLargest...find largest value  (Assignment 1 - LargestValue)The process
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
The largest integer among the X number
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... information : a) The largest integer among the X number of integers keyed in b
Determine Average by removing Largest and Smallest Number
Determine Average by removing Largest and Smallest Number In this section, you will learn how to remove largest and smallest number from the 10 numbers.... These numbers are then stored into an array in order to find the largest
Determining the largest number
Determining the largest number     ... the coding for determining the largest number amongst three. Here we have taken three...; conditions that can help you in finding the largest value one by one. 
to read number from user
to read number from user  1)print the positive equivalent of the number 2) check if the no is integer or not 3) find the square root of the number 4) find the cube of the number
Find prime factors of non prime number
Find prime factors of non prime number In this section, you will learn how to find the prime factors of the non prime number. Here we have prompted the user to enter any number. If the number entered by the user is prime then we have
A program to find the sum of odd number
A program to find the sum of odd number In this section you will learn how to find the sum of odd number in the series up to the given number in java... to the number provided by user. Within the loop checking for odd number
find factorial of any number using recursion
find factorial of any number using recursion  error in 14 line ; expected int rec( int a) ^ how to resolve this.please correct the code. import...)); System.out.println(?enter number?); int x=Integer.parseInt(br.readLine()); int result
Find out the prime number
Find out the prime number      ... to find out whether a given number is prime or not. Here we have used the 'for loop' statement and given the required condition for a prime number. As we know
Write a query to find the total number of rows in a table
Write a query to find the total number of rows in a table  Write a query to find the total number of rows in a table?   Hi, Here is the answer,ADS_TO_REPLACE_1 we can find the total number of rows in a table using
how to find square and cube of five number
how to find square and cube of five number  how to find square and cube of five number   Hi Friend, Try the following code:ADS_TO_REPLACE_1 <html> <script> document.writeln("Square of 5 numbers:<br>
how to find which user has modified the file
how to find which user has modified the file  how to find which user has modified the file
ModuleNotFoundError: No module named 'find-ida-user-dir'
ModuleNotFoundError: No module named 'find-ida-user-dir'  Hi, My... named 'find-ida-user-dir' How to remove the ModuleNotFoundError: No module named 'find-ida-user-dir' error? Thanks   Hi, In your
Find Cylinder area By inputting value from user
Find Cylinder area By inputting value from user  Hello Sir I need... user and then calculate area using this radius value. Please provide me...); double radius; System.out.print("Please enter a radius
How do I find out the number of parameters passed into function9. ?
How do I find out the number of parameters passed into function9. ?  How do I find out the number of parameters passed into function9
How can we find the number of rows in a result set using PHP?
How can we find the number of rows in a result set using PHP?   How can we find the number of rows in a result set using PHP
Program to Find Cube Root of any Number without using built in function
Program to Find Cube Root of any Number without using built in function  Please help me in finding cube root of any number without using Built in function in java
autogeneration of a random number and displaying it as a alert message to the user on clicking submit
automatically.But i want this number to be displayed when user click...autogeneration of a random number and displaying it as a alert message to the user on clicking submit  Hi, In my project order purchase system under
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
How to find out the friend user between two columns in sql database
How to find out the friend user between two columns in sql database  Hi, Can any one please tell me ..how to find out the friend user between two columns in sql database? In other words i wanted to get the corresponding data from
Write a program to find a factorial in any given number
; System.out.println("Enter the number to find the factorial"...Write a program to find a factorial in any given number This programming tutorial will teach you how to write a factorial of any given number
Find consecutive numbers whose sum is equal to input number.
Find consecutive numbers whose sum is equal to input number. In this section... to the input number. For this purpose, the user is allowed to input a positive natural number. The code then takes the number N given by the user and finds all
Find number of words begin with the specified character
Count number of words begin with the specified character In this section, you will learn how to count the number of words that begin with the specified character from the string. To do this, we have allowed the user to input a sentence
Find User Home Directory
Find User Home Directory        In this example we are find user home directory. We... "user.home" as key to get the user define home directory.ADS
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
Servlet Error Message based on user input
;test.jsp" which renders an input field to enter the name of the user...Servlet Error Message based on user input       In this example user is presented with a screen
plz give me program to this: Given a string and a number ‘n’, find the ‘n’th distinct repeating character.
plz give me program to this: Given a string and a number ?n?, find the ?n?th distinct repeating character.    Given a string and a number ?n?, find the ?n?th distinct repeating character. For example, Input: Abracadabra, 1
2. Given a string and a number ‘n’, find the ‘n’th distinct repeating character.
2. Given a string and a number ?n?, find the ?n?th distinct repeating character.    Given a string and a number ?n?, find the ?n?th distinct repeating character. For example, Input: Abracadabra, 1 Abracadabra, 2 Abracadabra, 3
generate random numbers and display the largest
it. Write a method to find the largest value in an array. Write a program that takes... to the screen and uses your method to find the largest value in the array, then prints...]; } } System.out.println("Maximum Number is: "+ max
How to Check Automorphic Number using Java Program
; public static void main(String args[]) { System.out.print("Enter any number...("not an automorphic number"); } } } } Output Enter any number :56...How to Check Automorphic Number using Java Program Automorphic numbers
how to find [count the number of integers whose value is less than the average value of the integers]
how to find [count the number of integers whose value is less than the average value of the integers]  Construct an algorithm that will prompt... amount to the screen integers from an operator at a terminal, and count the number
c++ array find the average mark, highest mark, lowest mark, number of students passing,
c++ array find the average mark, highest mark, lowest mark, number of students passing,    i need help in adding the c++ code for the average mark, highest mark, lowest mark, number of students passing, using array. 01
c++ array find the average mark, highest mark, lowest mark, number of students passing,
c++ array find the average mark, highest mark, lowest mark, number of students passing,    i need help in adding the c++ code for the average mark, highest mark, lowest mark, number of students passing, using array. 01
prime number
prime number  To check a number entered by user is prime or not?   Java check prime number import java.util.*; class CheckPrimeNumber... Scanner(System.in); System.out.println("Enter Number:"); int num
Find Twin Primes Number using Java
Find Twin Primes Number using Java In this section, you will learn how find... by 1 and the number itself. Here we are going to find twin primes. Twin Primes... the 'for loop' statement and set the required condition for a prime number
Convert Euro to dollar, need to be able to enter decimal!
the number of dollars). The program then repeatedly asks the user for a quantity... the equivalent number of dollars. When the user enters 0 or a negative amount...Convert Euro to dollar, need to be able to enter decimal!  Hi
Convert Euro to dollar, need to be able to enter decimal!
the number of dollars). The program then repeatedly asks the user for a quantity... the equivalent number of dollars. When the user enters 0 or a negative amount...Convert Euro to dollar, need to be able to enter decimal!  Hi
jQuery Convert string to number
jQuery Convert string to number In this tutorial , we will discuss about how to convert string (enter into input box) into number. In this example... alphabet/special character inside age input box : If you enter number greater
prime number
prime number  To check a number entered by user is prime
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
prime number
prime number  HI!I want a java program that accepts a number from user and displays whether it is a prime number or not using BufferedReader
Count number of "*"
Count number of "*"  I have this code to count the number of * from a string entered. but I need to find it from an text file. Any idea? import...(System.in)); System.out.println("Enter the String
ModuleNotFoundError: No module named 'largest-frontal-face-detector'
ModuleNotFoundError: No module named 'largest-frontal-face-detector'  ...: No module named 'largest-frontal-face-detector' How to remove the ModuleNotFoundError: No module named 'largest-frontal-face-detector' error
ModuleNotFoundError: No module named 'largest-frontal-face-detector'
ModuleNotFoundError: No module named 'largest-frontal-face-detector'  ...: No module named 'largest-frontal-face-detector' How to remove the ModuleNotFoundError: No module named 'largest-frontal-face-detector' error

Ads