Wednesday, October 30, 2013

1.08 - Multiplication table

/*
 * Autor: Juan Antonio Ripoll
 * Date: 30/10/13
 * 
 * Write a JAVA program to ask the user for a number and 
 * display its multiplication table, like this: 

   5 x 1 = 5 
   5 x 2 = 10 
   5 x 3 = 15 
   ... 
   5 x 10 = 50 
 * */

import java.util.Scanner;

public class Main {

 public static void main(String[] args) {
  Scanner in = new Scanner(System.in);
  
  System.out.print("Enter a number: ");
  int number1 = in.nextInt();
  
  for (int i=0; i<10;i++){
   System.out.println(number1 + " x " + (i+1) + " = " + 
     (number1 * (i+1)));
  }
 }
}

No comments:

Post a Comment