Make a Awesome Calculator in Java
If you are looking for Java coding for making a Awesome Calculator or want some help in coding of calculator in Java, you must follow this feed.
Coding
/**
* Write a description of class Calculator here.
*
* @author (Abhay)
* @version (04-09-2020)
*/
import java.util.Scanner;
public class Calculator
{
public void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter your first number:");
float num1= sc.nextFloat();
System.out.println("Enter your second number:");
float num2= sc.nextFloat();
System.out.println("Choice one of the following:");
System.out.println("1. Sum");
System.out.println("2. Diffrence");
System.out.println("3. Multiply");
System.out.println("4. Division");
int ch= sc.nextInt();
if (ch==1)
{
float a= num1 + num2;
System.out.println("Sum = " + a);
}
if (ch==2)
{
float s= num1 - num2;
System.out.println("Diffrence = " + s);
}
if (ch==3)
{
float m= num1 * num2;
System.out.println("Product = " + m);
}
if (ch==4)
{
float d= num1 / num2;
System.out.println("Division = " + d);
}
}
}
No comments