answersLogoWhite

0


Best Answer

public static void main(String[] args) {

int a = 5;

int b = 10;

int c;

c = a + b; // addition

c = a - b; // subtraction

c = a * b; // multiplication

c = a / b; // division

}

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

9y ago

Luckily, Java includes support for bitwise operators natively. & performs an AND operation, ^ performs exclusive OR and | performs inclusive OR. To make a program, simply declare two hex or binary integers and use the command printing(int1 &/^/| int2) to display the results

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

If you want the simplest answer possible, then you can simply throw it yourself.

throw new ArithmeticException();

If you want a more useful example:

int undefinedValue = 1 / 0;

This will throw an ArithmeticException.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

public void main()

{

for(int i=0;i<=100;i++)

{

System.out.println(i);

}

}

/*main function that increments i on each iteration of the loop and then prints it to the screen using System.out.println()

the result is

0

1

2

3

...

99

100

*/

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

For example, write the following in your main method: int a = 10; int b = 6; System.out.println("a = " + a); System.out.println("b = " + b); System.out.println("a + b = " + (a + b)); System.out.println("a / b = " + (a / b)); // Integer division! Result = 1 You can add other operators, whatever you like, including % for the remainder of an integer division.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

public class sumtest

{

public static void main(String args[])

{

float a,b,c,d;

a=10.90f;

b=20.90f;

c=a+b;

d=a-b;

System.out.println("Sum Of Two Numbers Is "+c);

System.out.println("Subtraction Of Two Numbers Is "+d);

}

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

I would normally use the word "algorithm" for solving more complicated problems. To do arithmetic operations, you just write the operation in the normal way, for example:

result = 1 + 2; //You can use constants...

result = a + b; //or variables

result = a - b;

result = a * b; //Use the asterisk for multiplication

result = a / b; //This is how you specify division

result = a + b * c; //You can combine various operations in one line. Multiplication is done first, in this case.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago


Write a program in java to perform binary operations on integer argument while the arguments and operators should be accepted using command line parameters?

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Just do the operations as you usually would, for example:

a = 1 + 2;

b = 3 * 5;

c = b / a;

etc.

(Note that all variables must be declared.)

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What a java program for arithmetic operations between two integers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a program in C for arithmetic operations between two integers your program should guide users with proper message or menu on the console?

Write a program in C for showing working of different logical operator in C.Your program should guide users with proper message/menu on the console. (5 Marks)


What is an arithmetic operator in c program?

An arithmetic operator is any of the "atomic" operators to do the following math operations: + addition - subtraction / division * multiplication % modulus division


What are the primary arithmetic operations a computer program can perform?

The four primary arithmetic operations a computer program can perform are addition, subtraction, multiplication and division.2 + 3 = 5 is an example of addition9 - 7 = 7 is an example of subtraction2 x 3 = 6 is an example of multiplication10 / 2 = 5 is an example of division


Writes a c program to find the sum of all integers between 1 and n?

Write a program to find the number and sum of all integers from 100 to 300 that are divisible by 11


Difference between a counter and a register?

A register can hold data, and it can be used for temporary storage or, in the case of an accumulator, it can participate in arithmetic or logical operations. A counter is a special case of a register. Usually, it can only be loaded, stored, or incremented, or used for the stack or as the program counter.


Write a statementin a java program to read 2 integers and dispay the number of interagers between them?

a=153 a=n%10;


How do you write a c program to calculate factorial using recursion?

unsigned long nfact(int n) if (n==2) return n else return n*nfact(n-1); For 32-bit integers, this program will fail at N==13, due to overflow. For 64-bit integers, it will fail at N==21. A solution for this is an arbitrary decimal arithmetic library, perhaps based on linked lists.


Application of arithmetic progression in design?

Arithmetic is important in design. This is true whether you are making a program for designs or you are trying to create a design.


What are the main components of CPU of a computer system?

The central processing unit (CPU) is the brain of your computer. CPU is the electronic circuitry within a computer that carries out the instructions of a computer program by performing the basic arithmetic, logical, control and input/output operations specified by the instructions. Following are the prime components of CPU: - The arithmetic logic unit (ALU), which performs arithmetic and logical operations. - The control unit (CU), which extracts instructions from memory and decodes and executes them, calling on the ALU when necessary.


What is the difference between a process and a function?

A program under execution is called a process. Hence a process will be loaded and run from the computer memory. A function is a small module within a program which gets some kind of work done. A simple example - In a program which does various Arithmetic operations like add, subtract, multiply etc. the code needed to perform addition may be placed inside an 'add' function and so on. When this program is run, it becomes a process in memory. It stays in memory until the process is 'killed' or it exits normally


How do you spell caulutar?

The closest word is "calculator" (arithmetic computing device or program).


How do you code the program using arithmetic exceptions?

Never.A program should handle exceptions, but should NEVER USE exceptions to control program flow.