answersLogoWhite

0

  1. import java.util.Scanner;
  2. public class average {
  3. static int i=0;
  4. static double sum = 0;
  5. static double average = 0;
  6. public static double calcSum(double sum){
  7. double count;
  8. Scanner input = new Scanner(System.in);
  9. while(i < 5){
  10. count = input.nextDouble();
  11. sum = sum + count;
  12. i++;
  13. }
  14. return sum;
  15. }
  16. public static double calcAverage(double average){
  17. double sum = calcSum(sum);
  18. average = calcSum(sum) / 5;
  19. return average;
  20. }
  21. public static void main(String[] args) {
  22. System.out.println("Please enter 5 numbers.");
  23. System.out.println("Sum is: "+calcSum(sum));
  24. System.out.println("Average is: "+calcAverage(average));
  25. }
  26. }
User Avatar

Wiki User

∙ 13y ago

What else can I help you with?

Related Questions

What is the sum of the first 102 counting numbers?

If you want to sum up numbers 1 to N, you can do it this way. Sum = (N+1)*(N/2).The reason this works: say you want to sum up 1 through 10. You have 10+1, 9+2, ..., 6+5. Each of these equals 11 [N+1]. You added 11 five times (N/2). Sum of 1 to 102 = (102+1)*(102/2) = 103*51 = 5253. You can check it by summing up the numbers with a spreadsheet.


What are the three consecutive numbers that sum up to 468?

let the three numbers be: n-1, n, n+1 their sum is equal to 3n 468=3n which means that n=156 the three numbers are 155, 156, 157


If you add up all the numbers from 1 to 1000 what do you get?

Sum of first n numbers = n/2(n +1) = 500 x 1001 = 500500


How do you get the sum of consecutive cubed numbers?

The sum of the first n cubed numbers is: [n*(n+1)/2]2 which is the same as the square of the sum of the first n numbers.


How do you calculate the sum of all numbers from 1 through 61?

The sum of the first "n" numbers is equal to n(n+1)/2.


Create a program that will display the sum of all numbers from 1 up to the input number?

to print the sum of first ten numbers:- void main() {int i,sum; sum=0; while(i&lt;=10) sum=sum+i; i=i+1; } printf("The sum is : %d",sum); }


What is the sum of the first 22 odd numbers?

The sum of a sequence is given by sum = n/2(2a + (n-1)d) where: n = how many a = first number of sequence d = difference between terms of sequence. For the first 22 odd numbers these are: n = 22 a = 1 d = 2 &rarr; sum = 22/2(2&times;1 + (22 - 1)&times;2)) = 22&sup2; = 484 The sum of the first n odd numbers is always n&sup2;: sum = n/2(2&times;1 + (n-1)2) = n/2(1 + (n-1))&times;2 = n(n) = n&sup2;


What is the sum of the numbers 1 through 35?

To sum numbers 1 through N, use this formula: (1 + N)*N/2, so (1+35)*35/2 = 630.


What is the Sum of first n natural numbers?

int sum = 0; int i; for(i = 0; i &lt; n; ++i) { sum += i; }


What is the sum of the first 100 even numbers?

n*(n+1)=sum 100*(100+1)=10100


What is the sum of the numbers from 1 to 100?

Sum of first n natural numbers is (n) x (n + 1)/2 Here we have the sum = 100 x (101)/2 = 50 x 101 = 5050


How do you write a C program to find sum of first n odd numbers?

/* sum of first n odd numbers uses:* sum = (first + last) * count_of_numbers / 2* first = 1* last = 2n - 1* count_of_numbers = n* => sum = (1 + 2n - 1) * n / 2* => sum = n * n*/int sum_odd (n)int n;{return n * n;}/** rest of program to* 1 - provide value of n* 2 - call above function* 3 - do something with result of function call* left as exercise for questioner.*/#includemain(){int n,i,sum=0;printf("Enter Number(n):");scanf("%d", &n);printf(" The sum of the first n numbers is %d",(n*(n+1))/2);return(0);}The following example adds up all the odd numbers up to and including 25.Code Example:#include #define iLAST_NUM 25 #define iFIRST_NUM 1 int main(void) { int iSum = 0; int iOddNum; /* starting at 1 loop through the odd numbers up to and including 25 by */ /* incrementing iOddNum by 2 each time. iSum keeps the running total of */ /* the odd numbers by adding iOddnum to itself on each iteration. */ for(iOddNum = iFIRST_NUM; iOddNum

Trending Questions
How do you make Javascript Hold a random Number. I'm making a guessing game and every time I click the button to submit my guess It creates a new number? What causes a loud tapping noise when water is turned on each morning from upstairs bathroom and the sound is coming from the drain pipes? What means the exclusive right over any idea or invention? How do you make a BINGO card using Java 3.0 that when you run again the number in the bingo card will not be seen again..it would be in random? What are examples of moments of inertia in sports equipment? What mean by active class in c plus plus? Is a dam a boon or a bane give one word answer? What is the chemical composition of the steel A42C1? What is an application of the human genome project that involves the insertion of normal genes int o cells with defective genes in an attemp to correcy genetic disorders? How can you tell if your mechanic replaced your engine? A list of antifederalists? What is the slogan for the railroad engineering school? What does flux mean? Communications signals represented in a binary format are said to be .? Can a silicon diode be forward biased if the anode voltage is negative? How many tons of 2b gravel are in a cubic yard after being tamped down 2b gravel is about half inch to inch and a half in size and not smooth? Closely related to pascal niklaus wirth also played a part in what computer language's creation? Can concrete leveling compound used on outside concrete? What does To contaminate with man made waste? Why would a function prototype contain a parameter type declaration such as double and?