Skip to content

Instantly share code, notes, and snippets.

@hk8084299
Created February 21, 2020 01:56
Show Gist options
  • Save hk8084299/7a7e8c9100e12f854c512ef3c7277035 to your computer and use it in GitHub Desktop.
Save hk8084299/7a7e8c9100e12f854c512ef3c7277035 to your computer and use it in GitHub Desktop.
Calculaor Assisgnment
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);
}
}
@hk8084299
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment