Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions ask user how many numbers to be inputted and determine the sum and highest number using an array in java

Have Programming Question? Ask it here!
 
 
 


Charmaine Waggay
ask user how many numbers to be inputted and determine the sum and highest number using an array in java
2 Answer(s)      2 years and 8 months ago
Posted in : Java Interview Questions


ask user how many numbers to be inputted and determine the sum and highest number using an array in java


Advertisement
View Answers

January 16, 2012 at 12:41 PM


import java.util.*;

class ArrayExample{

    public static void main(String[] args) {
        int largest = 0;
        Scanner input = new Scanner(System.in);
        System.out.print("How many numbers you want to display: ");
        int n=input.nextInt();
        System.out.println("Enter array values: ");
        int arr[] = new int[n];
        int sum=0;
        for(int i = 0; i < arr.length; i++) {
            arr[i] = input.nextInt();
            if (largest < arr[i]) {
                largest = arr[i];
            }
            sum+=arr[i];
        }
        System.out.println("Largest number is: " + largest);
        System.out.println("Sum of array values: " + sum);
    }
}


January 17, 2012 at 8:57 AM


Thanks a lot for the code.... :) it helps me a lot.... :) ^_^



Related Tutorials/Questions & Answers:
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
Check whether highest number is even or odd
Check whether highest number is even or odd In this section, you will learn how to check highest number between the two numbers and then determine whether... the highest number.After getting the highest number, we have created a condition
Advertisements
Find sum of all the elements of matrix using Java
Find sum of all the elements of matrix using Java A matrix is a rectangular array of numbers. The numbers in the matrix are called its entries or its elements... dimensional array. Now to determine the sum of all these elements, we have
determine the top 10 highest and 10 lowest in java
determine the top 10 highest and 10 lowest in java  hello, I have... java in INDIA, how the programming code in java to rank them. Thank you... that contains the codebooks and namesmembers. I want to make 10 the highest rank anyone
Determine Average by removing Largest and Smallest Number
and smallest number. Now to remove these highest and lowest numbers from the array, we have... will learn how to remove largest and smallest number from the 10 numbers and then determine the average. For this, an user is allowed to input 10 numbers
Find consecutive numbers whose sum is equal to input number.
Find consecutive numbers whose sum is equal to input number. In this section, you will learn how to display the consecutive natural numbers whose sum is equal... numbers which sum up to given number. Here is the code: import java.util.
using session variable determine the no of pages viewd by the user
using session variable determine the no of pages viewd by the user  using session variable determine the no of pages viewd by the user   Hi.../java/jsp/trackuserSession.html Thanks
Calculate the Sum of three Numbers
. In this section you will learn how to calculate the sum of three numbers by using three... Calculate the Sum of Three Numbers   ... how to calculate three integer number . First of all define class name "
Java count occurrence of number from array
Java count occurrence of number from array Here we have created an example that will count the occurrence of numbers and find the number which has... will ask for another number. Then using the ArrayList we determined the occurrence
Sum of a Number using Swing
Sum of a Number using Swing       In this section, you will learn how to sum of a number using swing...;); Step: Create a file "Calculate.java" to sum of a number using
C calculate sum of first and last element of array
will learn how to calculate sum of first and last element from the array of five... numbers of their choice. These numbers will get stored into the array as the user enters the number. Then using the index of the array, we have found first
Find HCF of three numbers in Java Program
Find HCF of three numbers in Java Program In this java tutorial section, you will learn how to determine the HCF (Highest Common Factor) or GCD (Greatest... Factors of 12=1,2,3,4,6,12 Here 4 is the highest number that can exactly
How many qusetions can you ask?
How many qusetions can you ask?  Hi I was very impressed following my very first question I asked regarding some coding. However I am not sure why any further questions have not yet been answered. Is this because they are more
Calculate sum of even and odd numbers in Java
Calculate sum of even and odd numbers In this section, you will learn how to read the file that contains even and odd numbers and calculate their sum... numbers from the file and then calculate their sum. Here is the code
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... number. import java.util.Scanner; public class Sum { public static
read a positive real numbers from highest to lowest
read a positive real numbers from highest to lowest  write a java program that will read a sequence of 10 positive real nos. entered by the user and will print the same numbers in sorted order from lowest to highest using arrays
JavaScript determine add, product of two numbers
JavaScript determine add, product of two numbers In this section, you will learn how to determine addition, multiplication, division and modulus of two...=document.form.text2.value; var sum=Number(num1)+Number(num2); alert
Java Sum of Digits
Java Sum of Digits In this Java Tutorial section, you will learn how to find the sum of multidigit number. For this purpose, we have allowed the user to enter multidigit number. User can enter any digit number but cannot exceed to 9 digit
Sum of first n numbers
Sum of first n numbers  i want a simple java program which will show the sum of first n numbers....   import java.util.*; public class...; } System.out.println("Sum of Numbers from 1 to "+n+" : "+sum
How to Check Automorphic Number using Java Program
How to Check Automorphic Number using Java Program Automorphic numbers are the numbers whose square ends with the number itself or you can say it is a number whose square ends with the given integer. For example,5 is an automorphic number
c++ array find the average mark, highest mark, lowest mark, number of students passing,
, highest mark, lowest mark, number of students passing, using array. 01 #include<iostream> 02 using namespace std; 03 int main() 04 { 05 int...c++ array find the average mark, highest mark, lowest mark, number of students
c++ array find the average mark, highest mark, lowest mark, number of students passing,
, highest mark, lowest mark, number of students passing, using array. 01 #include<iostream> 02 using namespace std; 03 int main() 04 { 05 int...c++ array find the average mark, highest mark, lowest mark, number of students
Find sum of the squares of Array elements
Find sum of the squares of Array elements In this section, you will learn how to compute the sum of the squares of the array elements. For this, we have allowed the user to enter 5 numbers, to be stored into the array. Then we have
how to add to numbers in java
how to add to numbers in java  how to add to numbers in java
Sum of positive and negative numbers
]; } } System.out.println("Sum of positive numbers: "+sum2); System.out.println("Sum of negative numbers: "+sum1...Sum of positive and negative numbers  Hi if someone could help
How to put text file numbers to array and check the position of numbers?
How to put text file numbers to array and check the position of numbers?   I have numbers in text file data.txt 12 9 8 3 1
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
Calculate sum and Average in java
. The given code accepts the numbers from the user using BufferedReader class. Then using... the sum by the total number of numbers, we have determined the average of numbers...Calculate sum and Average in java  How to calculate sum and average
The Array Palindrome Number in Java
The Array Palindrome Number in Java       This is a Java simple palindrome number program. In this section you will read how to uses palindrome one dimensional array
To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array
To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array
How to using Binary Search Array Java ?
How to using Binary Search Array Java ?  Hi, I am beginners in Java Programming Language. I am trying to create small application using Array functions. The problem is that how to use binary search array in Java. Please give
how to find the sum of integers in a string of sentence in java
how to find the sum of integers in a string of sentence in java  how to find the sum of integers in a string of sentence in java for e.g:--> abc d 2 3 21 the output should be 2+3+21=26
print the sum of even number from 1 to 100
print the sum of even number from 1 to 100  how to print the sum of even number from 1 to 100 using for loops? Thanks
Convert Number to Roman Number Using Java
Java Convert Number to Roman Numerals In this section, you will learn how to convert the number to roman number.  To do this, we have created a class named Roman in which we have stored some numbers and their roman numbers
how to find largest number? - Java Interview Questions
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... want to find the greater number which user enter on the console? Thanks
Hibernate One to many XML mapping array Example
In this section, you will learn how to do one to many mapping using array to retain mapping order in Hibernate
Generating Random Numbers to Fill array. Java Beginner needing help!
Generating Random Numbers to Fill array. Java Beginner needing help!  ... the permuted numbers. Make a second array and fill it with the numbers 1 to 10 in order. Pick one of the numbers from the second array randomly, remove it, and write
Java number calculation using while loop
Java number calculation using while loop In this tutorial, you will learn how... and secondNum inclusive. It also find the sum of all the even numbers between...+=num1; } num1++; } System.out.println("Sum Of Even Numbers: "+sum
Number in array
Number in array  How to write a program to check the number that we are entered from keyboard is in the given array
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. thanks. this is my java coding: import java.util.Scanner; import java.io.
how can i send a mail to a particular user from a many user dropdown list in jsp
how can i send a mail to a particular user from a many user dropdown list in jsp  how can i a sent a user question to a particular person from a drop down list in jsp
How to Create a ByteBuffer using Byte Array in java.
How to create a ByteBuffer using Byte Array in java.      ..., we will discuss how to creates a buffer using byte array. The ByteBuffer ... Description static ByteBuffer wrap(byte array
how to Insert Array Values Into Separate Rows using java?
how to Insert Array Values Into Separate Rows using java?  how to Insert Array Values Into Separate Rows using java?  class...) { String array[][]={{"1","Angel","Delhi"},{"2","John","Chennai"},{"3","William
Java find prime numbers without using break statement
Java find prime numbers without using break statement In this tutorial, you will learn how to find the prime numbers without using break statement. You all are aware of Prime Numbers, these are the numbers which are either divided
How to generate random number in java
How to generate random number in java In this section you will learn how to generate random number in java. Java API  provide a random class... numbers. If you are using java Math.random  it will generate only double value
Check whether the sum of alternate digit of a number is palindrome or not.
Check whether the sum of alternate digit of a number is palindrome... are going to check whether the sum of the alternate digit of a number entered by the user is palindrome or not. So, firstly we have to find the sum
Using sum() in hibernate criteria.
Using sum() in hibernate criteria.  How to calculate sum() in hibernate criteria by using projection?   You can calculate sum of any numeric value in hibernate criteria by using projection. Projection is an interface
Sum of array element in C
of the array is %d\n",sum); getch(); } void read(int c[],int i...() { void read(int *,int); void display(int *,int); int a[5],i,sum=0; clrscr(); printf("Enter five elements for an array \n"); read(a,5
java program based on array
java program based on array  write a program to create an array of 10 integers in main.accept values from the user in that array .now again ask... count() belonging to a class counter.within count findout how many numbers
Advertisements
 

 

 

DMCA.com