Advertisement
Shavit

P. 169 Ex. 7.12

Nov 3rd, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. // Shavit Borisov
  2. // CW
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class RealNumbers {
  7.  
  8.     public static void main(String[] args)
  9.    
  10.     {
  11.         Scanner in = new Scanner (System.in);
  12.        
  13.         int listSize;
  14.         int sum = 0;
  15.         double num;
  16.        
  17.         System.out.println("How long will your list be?");
  18.         listSize = in.nextInt();
  19.        
  20.         System.out.println("Enter numbers:");
  21.        
  22.         for (int i = 0; i < listSize; i++)
  23.         {
  24.             num = in.nextDouble();
  25.             sum = sum + (int)num;
  26.         }
  27.        
  28.         System.out.printf("The sum of your numbers regardless of digits after dot is %d.", sum);
  29.        
  30.         in.close();
  31.     }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement