Answer to Question #239178 in Programming & Computer Science for Alanoud

Question #239178

Write a program that allows the user to input two numbers. Use NUM1 & NUM2 as variables. The program should output 4 answers using 4 different operators which are +, ‐, /, * and MOD. Your Screen should look something like this:

Ans1 =

Ans2 =

Ans3 =

Ans4 =

*using netbeans*


1
Expert's answer
2021-09-19T10:52:19-0400


import java.util.Scanner;


public class Main {


	// 1- Sum Function (takes two integer parameters and returns their sum)
	static int Sum(int number1, int number2) {
		return number1 + number2;
	}


	// 2- Difference Function (takes two integer parameters and returns their
	// difference)
	static int Difference(int number1, int number2) {
		return number1 - number2;
	}


	// 3- Product Function (takes two integer parameters, performs division, returns
	// product)
	static int Product(int number1, int number2) {
		return number1 * number2;
	}


	// 4- Quotient Function (takes two integer parameters, performs division,
	// returns quotient)
	static float Quotient(int number1, int number2) {
		return (float) (number1) / (float) number2;
	}


	// 5- Remainder Function (takes two integer parameters, performs division and
	// returns remainder)
	static int Remainder(int number1, int number2) {
		return number1 % number2;
	}


	public static void main(String[] args) {
		Scanner keyboard = new Scanner(System.in);
		int number1;
		int number2;
		System.out.print("Ente the number 1: ");
		number1 = keyboard.nextInt();
		System.out.print("Ente the number 2: ");
		number2 = keyboard.nextInt();


		System.out.println("Sum: " + Sum(number1, number2));
		System.out.println("Difference: " + Difference(number1, number2));
		System.out.println("Product: " + Product(number1, number2));
		System.out.println("Quotient: " + Quotient(number1, number2));
		System.out.println("Remainder: " + Remainder(number1, number2));


		keyboard.close();


	}


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS