/* * Autor: Juan Antonio Ripoll * Date: 30/10/13 * * Write a JAVA program to print on screen the result of adding, * subtracting, multiplying and dividing two numbers typed by the user. * The remainder of the division must be displayed, too. It might look like this: Enter a number: 12 Enter another number: 3 12 + 3 = 15 12 - 3 = 9 12 x 3 = 36 12 / 3 = 4 12 mod 3 = 0 * */ 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(); System.out.print("Enter another number: "); int number2 = in.nextInt(); System.out.println(number1 + " + " + number2 + " = " + (number1 + number2)); System.out.println(number1 + " - " + number2 + " = " + (number1 - number2)); System.out.println(number1 + " x " + number2 + " = " + (number1 * number2)); System.out.println(number1 + " / " + number2 + " = " + (number1 / number2)); System.out.println(number1 + " mod " + number2 + " = " + (number1 % number2)); } }
Wednesday, October 30, 2013
1.07 - Several operations
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment