Wednesday, October 30, 2013

1.06 - Use of comments

/*
 * Autor: Juan Antonio Ripoll
 * Date: 30/10/13
 * 
 * Write a JAVA program to ask the user for three numbers 
 * and display their multiplication. 
 * The first line must be a comment with your name and surname. 
 * It MUST look as follows: 

   Enter the first number to multiply 
   12 
   Enter the second number to multiply 
   23 
   Enter the third number to multiply 
   2 
 * */

import java.util.Scanner;

public class Main {

 public static void main(String[] args) {
  Scanner in = new Scanner(System.in);
  
  System.out.println("Enter the first number to multiply");
  int number1 = in.nextInt();
  
  System.out.println("Enter the second number to multiply");
  int number2 = in.nextInt();
  
  System.out.println("Enter the third number to multiply");
  int number3 = in.nextInt();
  
  System.out.println(number1 + " x " + number2 + " x " + number3 + " = " + 
    number1 * number2 * number3);
 }

}

No comments:

Post a Comment