Question

In: Computer Science

Write a Java program to print the sum (addition), multiplication, subtraction, and division of two numbers....

Write a Java program to print the sum (addition), multiplication, subtraction, and division of two numbers.

Start your code by copying/pasting this information into an editor like notepad, notepad++, or IDLE:

public class Main {

public static void main(String[] args) {

// Write your code here

}

}

Sample input:

Input first number: 125
Input second number: 24

Sample Output:
125 + 24 = 149
125 - 24 = 101
125 x 24 = 3000
125 / 24 = 5

*Please include what system you used to write this. My course is not very descriptive, thank you!

Solutions

Expert Solution

JAVA code:

import java.util.*
;class sorting {
    public static void main(String[] args) {
        //scanner class
        Scanner sc = new Scanner(System.in);
        //taking inputs
        System.out.print("Input first number: ");
        int x = sc.nextInt(); //input x
        System.out.print("Input second number: ");
        int y = sc.nextInt();  //input y

        System.out.println();
        //printing results
        System.out.println(x + "+" + y + "=" + (x + y));  //addition
        System.out.println(x + "-" + y + "=" + (x - y));  //subtraction
        System.out.println(x + "x" + y + "=" + (x * y));  //multiplicaation
        System.out.println(x + "/" + y + "=" + (x / y));  //division


    }
}

OUTPUT:


Related Solutions

Write a Python program that will perform various calculations (addition, subtraction, multiplication, division, and average). The...
Write a Python program that will perform various calculations (addition, subtraction, multiplication, division, and average). The program will add, subtract, multiply, or divide 2 numbers and provide the average of multiple numbers inputted from the user. You need to define a function named performCalculation which takes 1 parameter. The parameter will be the operation being performed (+,-,*,/). This function will perform the given prompt from the user for 2 numbers then perform the expected operation depending on the parameter that’s...
There are four basic functions in math. They are addition, subtraction, multiplication and division. Children in...
There are four basic functions in math. They are addition, subtraction, multiplication and division. Children in 1st grade focus on addition. They are required to memorize their addition facts from 1 to 12. Create a function that prompts the user to enter a number between 1 and 12. Then display - using the input supplied - the addition and subtraction math facts for that number from 1 to 12 for the number entered. The output should be the results of...
There are four basic functions in math. They are addition, subtraction, multiplication and division. Children in...
There are four basic functions in math. They are addition, subtraction, multiplication and division. Children in 1st grade focus on addition. They are required to memorize their addition facts from 1 to 12. Create a function that prompts the user to enter a number between 1 and 12. Then display - using the input supplied - the addition and subtraction math facts for that number from 1 to 12 for the number entered. The output should be the results of...
C -Language Create a simple calculator that performs addition, subtraction, multiplication, and division. Your program should...
C -Language Create a simple calculator that performs addition, subtraction, multiplication, and division. Your program should prompt the user for the operation they wish to perform followed by the numbers they wish to operate on. You should have a function for each operation and use branches to determine which function to call. I need this to make any integers given, into decimal numbers, such as 3 to 3.0, or 2 to 2.0, also, so that I can multiply or add...
Write a Java program that uses nested for loops to print a multiplication table as shown...
Write a Java program that uses nested for loops to print a multiplication table as shown below.   Make sure to include the table headings and separators as shown.   The values in the body of the table should be computed using the values in the heading   e.g. row 1 column 3 is 1 times 3.
I need it in java. Write a program that will print if n numbers that the...
I need it in java. Write a program that will print if n numbers that the user will input are or not within a range of numbers. For that, your program needs to ask first for an integer number called N that will represent the number of times that will ask for other integer numbers. Right after, it should ask for two numbers that will represent the Min and Max for a range. Lastly. it will iterate N number times...
Ahrithmetic calculation about scientific notation. Mixed unit and multiplication, addition, subtraction, division too. this is my...
Ahrithmetic calculation about scientific notation. Mixed unit and multiplication, addition, subtraction, division too. this is my question above, please help me I need it to study.
Write a java program of a multiplication table of binary numbers using a 2D array of...
Write a java program of a multiplication table of binary numbers using a 2D array of integers.
JAVA Write a program to sum the numbers from 1 to 100 that are divisible by...
JAVA Write a program to sum the numbers from 1 to 100 that are divisible by 7, and compute the average of those numbers, print both the sum and the average with appropriate messages to the screen. Run the program. Capture the console output. Put the program code and console output at the end of your text file,
use java Write a program that, given two binary numbers represented as strings, prints their sum...
use java Write a program that, given two binary numbers represented as strings, prints their sum in binary. The binary strings are comma separated, two per line. The final answer should not have any leading zeroes. In case the answer is zero, just print one zero i.e. 0 Input: Your program should read lines from standard input. Each line contains two binary strings, separated by a comma and no spaces. Output: For each pair of binary numbers print to standard...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT