Advertisement
thotfrnk

multiples.java

Nov 10th, 2022
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class multiples {
  3.     public static void main(String[] args) {
  4.  
  5.         //Develop a java program to calculate the multiples of a given number using a for loop.
  6.         //Have the user enter a number, and then use a for loop to display all the multiples of that number from 1 to 12.
  7.  
  8.         Scanner input = new Scanner (System.in);
  9.  
  10.         int num, multi, num_multi;
  11.  
  12.         System.out.println("Enter a number: ");
  13.         num = input.nextInt();
  14.  
  15.         for(multi = 1; multi <= 12; multi++) {
  16.             num_multi = num * multi;
  17.  
  18.             System.out.println(num_multi+"");
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement