import java.util.*;
public class avg {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("How many numbers: ");
int amount = input.nextInt();
double [] numbers = new double[amount];
double count = 0;
double avg;
for(int i = 0; i < numbers.length; i++){
System.out.print("Number: ");
numbers[i] = input.nextDouble();
count += numbers[i];
}
avg = count / amount;
System.out.println(avg);
}
}
The below method is written in the assumption that, the n numbers are sent as an ArrayList of Integer values. public void computeSumAndAvg(ArrayList lst){ Iterator itr = lst.iterator(); int sum = 0; float average = 0; int count = 0; while(itr.hasNext(){ Integer val = (Integer) itr.next(); sum = sum + val.intValue(); count++; } average = sum/count; System.out.println("Sum is: " + sum) ; System.out.println("Average is: " + average) ; }
2.35 is not an integer.
Store the absolute value of the desired integer in a variable. Multiply the absolute value by two. Substract the new integer by the old integer.
Integer programming is a special kind of an optimising problem where the solution must be an integer.
ZERO 0
Dim average as doubleDim numberA as integer = 23Dim numberB as integer =2Dim numberC as integer = 27 'continue until you have enough numbersaverage = numberA + numberB + numberC '...average = average / 3 ' replace 3 with the amount of numbers used.
55
15 is, itself, an average number.
Because of each elements many isotopes they the do not average out to a integer.
3 cubed is 3^3=27 and 5 squared is 5^2=25. A cube of an integer is that integer multiplied by itself three times. A square of an integer is that integer multiplied by itself two times. The average of two numbers is those two numbers added together and divided by two. Any average is the numbers added together, then divided by the number of integers. Therefore, the average is (27+25)/2=52/2=26.
The below method is written in the assumption that, the n numbers are sent as an ArrayList of Integer values. public void computeSumAndAvg(ArrayList lst){ Iterator itr = lst.iterator(); int sum = 0; float average = 0; int count = 0; while(itr.hasNext(){ Integer val = (Integer) itr.next(); sum = sum + val.intValue(); count++; } average = sum/count; System.out.println("Sum is: " + sum) ; System.out.println("Average is: " + average) ; }
517
Take two integers 1 2 add them together 1+2=3 devide by the number of integers (2) to get the average 3/2= 1.5 Your answer is 1.5 and you need to ask yourself if 1.5 is an integer to find the answer to your question.
No, it is an integer.
33. ( how i got it 25+41= 66; 66/2= 33)
The absoluate value of a positive integer is the integer itself.The absoluate value of a positive integer is the integer itself.The absoluate value of a positive integer is the integer itself.The absoluate value of a positive integer is the integer itself.
Yes, the square of an integer is always an integer.