Advertisement
BielTheGamer12

Somando 30 números usando o For

Feb 20th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. package usandofor;
  2. import java.util.Scanner;
  3. public class UsandoFor {
  4.     public static void main(String[] args) {
  5.         // TODO code application logic here
  6.         //declarando variável
  7.         int n1,r = 0;
  8.         Scanner lul = new Scanner (System.in);
  9.         //laço for
  10.         for(int i=0;i<=30;i++){
  11.         System.out.println("Digite aqui um número: ");
  12.         n1 = lul.nextInt();
  13.         r = n1+i;
  14.     }//fim laço for
  15.         // mostrando o resultado
  16.         System.out.println("Sua soma foi de: " + r);
  17.    }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement