Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1.  
  2. /**
  3. * Practicing Looping
  4. */
  5. import java.util.Scanner;
  6. public class Looping
  7. {
  8. public static void main(String args[])
  9. {
  10. System.out.println(" Enter any number. This number will be multiplied by 1,2,3,4, and 5");
  11.  
  12. Scanner fromKB = new Scanner(System.in);
  13.  
  14. double num = fromKB.nextDouble();
  15.  
  16. fromKB.close();
  17.  
  18. for(int i=1; i<=5; i++)
  19. System.out.println( i+ "*" +num+ "=" + (num*i));
  20. System.out.println(" ");
  21.  
  22. System.out.println("Now your number will be powered until it reaches over 1000");
  23.  
  24. int r = 1;
  25. while (num >= 1)
  26.  
  27. {
  28. System.out.println(num);
  29. num = num *r;
  30. r++;
  31.  
  32. if (num >= 1000) {
  33. System.out.println(num);
  34. break;
  35. }
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement