answersLogoWhite

0

import java.util.Scanner;

public class Summer{
public static void main (String[]args){

int sum=0;
for(int i=1; i<=50; i++){
System.out.println("Enter the number (50 times)");
Scanner kb = new Scanner (System.in);
int input=kb.nextInt();
sum+=input;
}

System.out.println("The sum" +sum);
}

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Write a program to show the concept of recursion in java?

public class Main{ public static void main(String[] args){ System.out.println("the factorial of 5 is: " + getFactorial(5)); } public static int getFactorial(int num){ return num + getFactorial(num-1); } }


Will you Write a C program to print the pattern of your choice?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { int num; for(num=1;num&lt;=100;num++) { printf("%d",num); } getch(); }


Write a method which displays first 50 prime numbers?

Implement an isPrime method int JAVA with this: int count = 0, num = 2; while(count &lt; 50) { if(isPrime(num)) count++; num++; }


How do you write a c program to convert binary code to Gray code?

unsigned binary_to_gray (unsigned num) { return num ^ (num &gt;&gt; 1); } unsigned gray_to_binary (unsigned num) { /* note: assumes num is no more than 32-bits in length */ num ^= (num &gt;&gt; 16); num ^= (num &gt;&gt; 8); num ^= (num &gt;&gt; 4); num ^= (num &gt;&gt; 2); num ^= (num &gt;&gt; 1); return num ; }


How do you write a program to read a value and display all prime numbers up to the value?

#include#includebool is_prime(unsigned num) {unsigned max, factor;if (num


Write a C-like program fragment that calculate the factorial function for argment 12 with do while loop?

#!/usr/bin/perl print factorial($ARGV[11]); sub factorial { my($num) = @_; if($num == 1) { return 1; # stop at 1, factorial doesn't multiply times zero } else { return $num * factorial($num - 1); # call factorial function recursively } }


Write a program to calculate the average of n numbers using array?

C:#includeint main(){int num,sum,avg=0,i;printf("enter a number");scanf("%d",&num);for(i=0;i


How do you write a program in lisp to find if a number is prime or not?

(defun prime (num) (if (&lt; 2 num) (do ((dividend 2 (1 + dividend)) (chk-to (sqrt num))) ((equal (rem num dividend) 0)) (when (&lt;= chk-to dividend) (return t))) t))


How do you write a C program to reverse the 3 digits of a number using while loop?

unsigned reverse (unsigned num) { unsigned rev = 0; while (num) { rev *= 10; rev += num % 10; num /= 10; } return rev; }


How do you Write a program that determines the number of occurrences of each digit in a given integer n?

there could be a part in it like this: int num, digit; int count [10]; do { digit = num%10; num != 10; ++count[digit]; } while (num);


Find the absolute value write a program of a no entered through the keyboard?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; int main () { int num; printf("enter the number"); scanf("%d",&amp;num); if(num&lt;0) num=(-1)*num; printf("absolute value=%d",num); getch(); return 0; }


Write a java program to show following pattern 5 5 4 5 4 3 5 4 3 2 5 4 3 2 1?

// num = the highest number to start with final int num = 5; // Go through each value from num through 1. for (int n = num; n &gt; 0; --n) { // For each value, print each value from num all the way down to the value. for (int m = num; m &gt;= n; --m) { System.out.print(m); System.out.print(' '); } }