Guest User

Untitled

a guest
Mar 17th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. /** Program Excercise 2
  2. * Summary: A number input program
  3. * Author: Christopher J Linney
  4. * Date: March 4, 2015
  5. **/
  6.  
  7. import java.util.Scanner; // Java package for the Scanner class is used.
  8.  
  9. class Number
  10. {
  11. public static void main(String args[])
  12. {
  13. //the maximum amount of numbers the user asks to put in
  14. int n = 5;
  15.  
  16. //
  17. System.out.println("Enter a 5 numbers to get the sum");
  18. Scanner in = new Scanner(System.in);
  19. n = in.nextInt();
  20.  
  21. if (n <= 5)
  22. {
  23. n = n++;
  24. }
  25.  
  26. else {
  27. System.out.println("You have already entered 5 numbers");
  28. }
  29.  
  30. System.out.println("The sum of 5 numbers is " + n);
  31.  
  32. }
  33.  
  34.  
  35. }
  36.  
  37.  
  38. } // end excercise 2
Add Comment
Please, Sign In to add comment