Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package arithmetic;
- import java.util.Scanner;
- public class Arithmetic {
- public static void main(String[] args) {
- // New scanner for input created
- Scanner input = new Scanner (System.in);
- // Creation of variables to calculate; x and y being factors,ans being the answer.
- int x, y, ans;
- double a, b, sol;
- // Inputting of values to factors.
- System.out.print("Enter the first whole number value: ");
- x = input.nextInt();
- System.out.print("Enter the second whole number value: ");
- y = input.nextInt();
- a = x;
- b = y;
- // Header for integer arithmetic
- System.out.println("\nIntegers: \n");
- // Addition
- ans = x + y;
- System.out.println(x + " plus " + y + " = " + ans);
- // Subtraction
- ans = x - y;
- System.out.println(x + " minus " + y + " = " + ans);
- // Multiplication
- ans = x * y;
- System.out.println(x + " times " + y + " = " + ans);
- // Division
- ans = x / y;
- System.out.println(x + " divided by " + y + " = " + ans);
- // Modulus Division
- ans = x % y;
- System.out.println("The remainder of " + x + " divided by " + y + " is " + ans);
- // Doubles
- System.out.println(" \nDoubles: \n");
- sol = a + b;
- System.out.println(a + " plus " + b + " = " + sol);
- sol = a - b;
- System.out.println(a + " minus " + b + " = " + sol);
- sol = a * b;
- System.out.println(a + " times " + b + " = " + sol);
- sol = a / b;
- System.out.println(a + " divided by " + b + " = " + sol);
- sol = a % b;
- System.out.println("The remainder of " + a + " divided by " + b + " is " + sol);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement