0% found this document useful (0 votes)
18 views

Calculator Programm in Java

The document describes a Java program that acts as a basic calculator. It takes in two numbers and an operator from the user using Scanner methods. It then performs the calculation based on the operator selected and prints out the result. The program uses a switch statement to select the appropriate calculation - addition, subtraction, multiplication, division or modulo.

Uploaded by

chiraghz
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Calculator Programm in Java

The document describes a Java program that acts as a basic calculator. It takes in two numbers and an operator from the user using Scanner methods. It then performs the calculation based on the operator selected and prints out the result. The program uses a switch statement to select the appropriate calculation - addition, subtraction, multiplication, division or modulo.

Uploaded by

chiraghz
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

hackingzo ne s.

co m

http://hackingzo nes.co m/?p=6221

Calculator programm in java


import java.util.Scanner; class cal { int a,b,c,d; void cala() { System.out.println(enter two no); Scanner s1=new Scanner(System.com); a=s1.nextInt(); Scanner s2=new Scanner(System.com); b=s2.nextInt(); System.out.println(Enter yor choice); System.out.println(1 -> f or addition); System.out.println(2 -> f or subtraction); System.out.println(3 -> f or multiplication); System.out.println(4 -> f or divison); System.out.println(5 -> f or modulos); Scanner s3=new Scanner(System.com); c=s3.nextInt(); switch(c) { case 1: d=a+b; System.out.println(d); break; case 2: d=a-b; System.out.println(d); break; case 3: d=a*b; System.out.println(d); break; case 4: d=a/b; System.out.println(d); break; case 5: d=a%b; System.out.println(d); break; def ault: System.out.println(enter correct choice); } } } public class Calculator_using_scanner

{ public static void main(String arg[]) { cal cobj=new cal(); cobj.cala(); } }

Relat ed Post
SHA1 Hash generating program in java MD5 Hash generating program in java Java Program to Find Network Interf ace Java Program to f ind Your IP Address and LoopBack Address Shif t Operator Program in Java Enter your email address:

Delivered by FeedBurner

Post Footer automatically generated by Add Post Footer Plugin f or wordpress.

You might also like