MariusTheMaster

Multiplying until 100 with while

Sep 20th, 2023
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. //Multiplying until 100 with while
  2. // Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
  3. // then press Enter. You can now see whitespace characters in your code.
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class Main {
  8.     public static void main(String[] args) {
  9.         int no1;
  10.         double res;
  11.         int h;
  12.         h = 1;
  13.         res = 0;
  14.         // Press Alt+Enter with your caret at the highlighted text to see how
  15.         System.out.println("Multiplying until 100");
  16.         System.out.println("Enter any number");
  17.         Scanner a = new Scanner(System.in);
  18.         no1 = a.nextInt();
  19.         while (res < 100) {
  20.             if(res <= 100){
  21.                 System.out.println(no1 + " * " + h + " = " + res);
  22.             }
  23.             h++;
  24.             res = no1 * h;
  25.         }
  26.  
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment