Lowest price ever! Learn Generative AI for 48% less!
Get my discount0
What the mistake ????
import java.util.*; //java calculator buttons public class Program { public static void main(String[] args) { Scanner s=new Scanner (System.in); int a=s.nextInt(); char c=s.next(); int b=s.nextInt(); int sum=a+b; int dif=a-b; int mul=a*b; int div=a/b; int remain=a%b; switch(c){ case'+':System.out.println("Addition = "+sum); break; case'-':System.out.println("Subtraction = "+dif); break; case'*':System.out.println("Product = "+mul); break; case'/':System.out.println("Quotient = "+div); break; case'%':System.out.println("Remainder = "+remain); break; default :System.out.println("Invalid operation"); } } }
4 Answers
+ 1
Save code and share link here..
Mention the problem you getting by this code ...!!
+ 1
suraj Choudhary
It sometimes depends on your try so mention your error or trouble..
In your program, replace char c=s.next(); with
char c=s.next().charAt(0);
0
Please find
0
Hope this helps you
https://code.sololearn.com/cK5xhZtG45h0