Given two integers a and b, your task is to calculate :- a+b a-b a*b a/b Input User Task: Since this will be a functional prob | SoloLearn: Learn to code for FREE!

+1

Given two integers a and b, your task is to calculate :- a+b a-b a*b a/b Input User Task: Since this will be a functional prob

6/28/2020 11:47:19 AM

Lucky Khobragade

38 Answers

New Answer

+8

To post a challenge for other users please dont ise QA! This is obly for Questions! Like this: https://www.sololearn.com/post/451756/?ref=app

+4

Lucky Khobragade It's too easy 1. Assign two integral values to the variables a and b 2. For addition, take third variable eg - c, and add them int c = a+b; 3. The same goes for division, multiplication and subtraction

+3

Check this void num(int a, int b) int s = a+b; S.O.Pln(s); return s; } //add others here psvm(String args[]) { class ob = new class() ob.new(5.10) } This is for addition You you can easily do it for other operators using functions and

+1

Hi there 👋 Please use this thread for programming queries only. Happy Coding https://www.sololearn.com/discuss/1316935/?ref=app

+1

Hello Lucky Khobragade If this is your homework please show us your attempt.

+1

How to get user input: https://www.sololearn.com/learn/Java/2220/

+1

Maybe you should give us your complete task. And I still don't know what you mean with static void operators. You can have static members or static methods. And the keyword void is only used for methods without return type. Maybe you are confusing something.

0

But I don't know n how to use that static void operators()

0

I am solving that by traditional methods

0

I know bt it not work

0

What do you mean with static void oparators()? static void means that your method belongs to the class and does not return a value.

0

I said that use static void operators (int a, int b) for arithmetic operations

0

I don't know n that wait I give u ss

0

int a and int b are two primitive variables from type integer. +, * , - and / are math operators. So you can just do the math: int result = a + b; Same for other calculations. Or you can write a method for each operation: public static int add(int a, int b){ return a+b; }

0

Here we have to not use main method

0

I have to also give the value to a and b how that's possible

0

I think you should read the java course again. int a = 3; int b = 10; Or use user input. You will find it in the java course.

0

Ok bt I didn't find that's why I posted here

0

Lucky Khobragade It is part of the basics. A tip: the learn section has also a search bar.

0