Advertisement
cesarnascimento

5 numeros informar media e soma for

May 30th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. package exercicios;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class ex8 {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner sc = new Scanner(System.in);
  9.        
  10.         int num,soma = 0,media;
  11.        
  12.         for(int i = 0 ; i< 5; i++){
  13.             System.out.println("Digite o número: ");
  14.             num = sc.nextInt();
  15.             soma += num;
  16.            
  17.         }
  18.        
  19.         media = soma /5;
  20.        
  21.         System.out.println("Soma: "+soma+"\nMedia: "+media);
  22.     }
  23.     /* César N. */
  24. }
  25. //faça um programa que leia 5 numeros e informe a soma e a media dos numeros
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement