Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class multiples {
- public static void main(String[] args) {
- //Develop a java program to calculate the multiples of a given number using a for loop.
- //Have the user enter a number, and then use a for loop to display all the multiples of that number from 1 to 12.
- Scanner input = new Scanner (System.in);
- int num, multi, num_multi;
- System.out.println("Enter a number: ");
- num = input.nextInt();
- for(multi = 1; multi <= 12; multi++) {
- num_multi = num * multi;
- System.out.println(num_multi+"");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement