Created
February 21, 2020 01:56
-
-
Save hk8084299/7a7e8c9100e12f854c512ef3c7277035 to your computer and use it in GitHub Desktop.
Calculaor Assisgnment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company.demo; | |
import java.util.Scanner; | |
public class Caculator1 { | |
public static void main(String[] args) { | |
Calculator cal=new Calculator(); | |
Scanner scr= new Scanner(System.in); | |
System.out.println("Enter First number: "); | |
int a= scr.nextInt(); | |
System.out.println("Enter Second Number: "); | |
int b= scr.nextInt(); | |
// int c= a+b; | |
System.out.println(" The result of c :" + c); | |
System.out.println("for Addition, enter 1, " + "for Subtraction, enter 2," + " for Multiplication, enter 3,"+ "for Division, enter 4"); | |
int res= scr.nextInt(); | |
if (res==1){ | |
int result= cal.add(a,b); | |
System.out.println("result is " + result); | |
} | |
else if(res==2){ | |
int result= cal.sub(a,b); | |
System.out.println("result is " + result); | |
} | |
else if(res==3){ | |
int result= cal.mult(a,b); | |
System.out.println("result is " + result); | |
} | |
else if(res==4){ | |
int result= cal.div(a,b); | |
System.out.println("result is " + result); | |
} | |
// long c = a + b; | |
// System.out.println("Total number for c is :" + c); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Mine one is not working!!
add, sub, mult and div( all are red color).
can you please let me know why it's happening?
Thanks!
Kabir