Guest User

sum+

a guest
Nov 30th, 2014
539
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. import static java.lang.Integer.sum;
  2. import java.util.Scanner;
  3.  
  4. public class Week2 {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner reader = new Scanner(System.in);
  8.         int sum = 0;
  9.         int read;
  10.  
  11.         System.out.println("First number: ");
  12.         read = Integer.parseInt(reader.nextLine());
  13.         sum = read;                                  //sum=read
  14.  
  15.         System.out.println("Second number: ");
  16.         read = Integer.parseInt(reader.nextLine());
  17.         sum += read;                                  //sum(second)=sum(first)+read  
  18.  
  19.         System.out.println("Third number: ");
  20.         read = Integer.parseInt(reader.nextLine());
  21.         sum += read;                                 //sum(third)=(sum(first)+sum(second))+ read
  22.                                                      //sum(third)=sum
  23.  
  24.         System.out.println("Sum: " + sum);
  25.  
  26.     }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment