desislava_topuzakova

03. Sum Numbers

Feb 5th, 2022
924
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SumNumbers_03 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int controlNumber = Integer.parseInt(scanner.nextLine());
  7.         int sum = 0;
  8.         while (sum < controlNumber) {
  9.             int number = Integer.parseInt(scanner.nextLine());
  10.             sum += number;
  11.         }
  12.         System.out.println(sum);
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment