Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Practicing Looping
- */
- import java.util.Scanner;
- public class Looping
- {
- public static void main(String args[])
- {
- System.out.println(" Enter any number. This number will be multiplied by 1,2,3,4, and 5");
- Scanner fromKB = new Scanner(System.in);
- double num = fromKB.nextDouble();
- fromKB.close();
- for(int i=1; i<=5; i++)
- System.out.println( i+ "*" +num+ "=" + (num*i));
- System.out.println(" ");
- System.out.println("Now your number will be powered until it reaches over 1000");
- int r = 1;
- while (num >= 1)
- {
- System.out.println(num);
- num = num *r;
- r++;
- if (num >= 1000) {
- System.out.println(num);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement