0
Problem Statement Given two integers a and b, your task is to calculate and print the following four values:
Problem Statement Given two integers a and b, your task is to calculate and print the following four values:- a+b a-b a*b a/b Input The input contains two integers a and b separated by spaces. Constraints: 1 <= b <= a <= 1000 It is guaranteed that a will be divisible by b Output Print the mentioned operations each in a new line.
11 Antworten
+ 3
Those are not questions, those are statements. If you need help, you to ask a specific question and share your own attempt.
+ 3
Altaf Khan
Save code in playground and share link with clear problem description and your trouble or error details..
Your code have wrongly structured. See class is a block of code so you need start class by using braces { } but you are missing braces.
class Main {
// code
}
And while loop is also have a block of code.if you miss braces then only single next line comes under loop. So you have 2 infinite loops then.
While you need to print all operations then there is no need to ask 3rd input and asking notifications for options.
Multiply, devide are undefined variables. define those.
+ 2
What exactly is your question?
+ 2
Do not DM me with the entire statement as well. State your issue here.
+ 2
Please show us your attempt, so we can see where you make mistake and help you.
You probably won't learn anything if we solve task for you, we learn most by making mistakes and thought practice.
+ 2
Also tag relevant language, you tagged javascript but code look like java, this 2 are not same language.
https://code.sololearn.com/W3uiji9X28C1/?ref=app
+ 1
Problem Statement
Given two integers a and b, your task is to calculate and print the following four values:-
a+b
a-b
a*b
a/b
+ 1
1 <= b <= a <= 1000
+ 1
class main
public static void main (String[] args) {
int m,n,opt,add,sub,mu;
double split;
scanner s =new scanner (System.in);
System.out.print("Enter the first digit:");
m=s.nextlnt();
while(true)
System.out.println("enter the second number:");
n=s.nextlnt();
while(true)
System.out.println("Enter 1 to add number");
System.out.println("Enter 2 to substract number");
System.out.println("enter 3 to multiply");
System.out.println("enter 4 divide");
System.out.println("enter 5 to exit");
opts=s.nextlnt();
add=a+b;
System.out.println("result" +add);
sub=a-b;
System.otu.println("result"+sub);
multiply = a*b
System.out.println("result"+multiply);
divide = (double)a/b
System.out.println("result"+divide);
System.exit(0);}
0
Ok
0
Sir