Monday, September 7, 2020

Simple Calculator Using Java | Full Details | Source Code | How to Make

Simple Calculator Using Java

In this Java Program You Can Divide, Multiply, Substract Or Add any type of Numbers.

If You are a Advanced Java Programmer, Then It is Not For You. This Program Is Only For Beginners Or InterMediate Java Programmers Because It is Not GUI(Graphical User Interface) Program.

Things to Do Before Copying Codes

1. Make Sure You have Installed Java and Its JDK

2. Create A New Folder WhereEver You Want

3. Create a New File in The Folder Name "Anything.bat"

4. Right Click On the File and Click Edit And Paste the Given Text There.

java -jar JavaCalculator.jar


    import java.util.Scanner;
              
public class Main {
              
                  public static void main(String[] args) throws InterruptedException {
                      for (int i = 0; i < 2000; i++) {
                          Scanner scanner = new Scanner(System.in);
                          double a, b;
                          System.out.print("Enter The First Number : ");
                          a = scanner.nextDouble();
                          System.out.print("Enter the Second Number : ");
                          b = scanner.nextDouble();
                          System.out.println();
                          System.out.println();
                          System.out.println();
                          System.out.print("You have Entered : ");
                          System.out.print(a);
                          System.out.print(" and ");
                          System.out.print(b);
                          System.out.println();
                          System.out.println();
                          System.out.println();
                          System.out.println("Press 1 for Addition");
                          System.out.println();
                          System.out.println("Press 2 For Substraction");
                          System.out.println();
                          System.out.println("Press 3 for Multiplication");
                          System.out.println();
                          System.out.println("Press 4 For Division");
                          
                          
                          int selection = scanner.nextInt();
                          switch (selection) {
                              case 1:
                                  System.out.println("Adding These Numbers ..... Please Wait");
                                  Thread.sleep(3000);
                                  System.out.println();
                                  System.out.println();
                                  System.out.print("The Sum of These Numbers is : ");
                                  System.out.println(a + b);
                                  break;
                              case 2:
                                  System.out.println("Substracting These Numbers ..... Please Wait");
                                  Thread.sleep(3000);
                                  System.out.println();
                                  System.out.println();
                                  System.out.print("The Substraction Of these Two Numbers is : ");
                                  System.out.println(a - b);
                                  break;
                              case 3:
                                  System.out.println("Multiplying These Numbers ..... Please Wait");
                                  Thread.sleep(3000);
                                  System.out.println();
                                  System.out.println();
                                  System.out.print("The Multiplication Of these Two Numbers is : ");
                                  System.out.println(a * b);
                                  break;
                              case 4:
                                  System.out.println("Dividing These Numbers ..... Please Wait");
                                  Thread.sleep(3000);
                                  System.out.println();
                                  System.out.println();
                                  System.out.print("The Division of These two Numbers Is : ");
                                  System.out.println(a / b);
                                  break;
                              default:
                                  System.out.println();
                                  System.out.println("Invalid Content, Press one of the Given Numbers to perform a Operation");
                                  break;
                                  
                                  
                          }
                          System.out.println();
                          System.out.println();
                          System.out.println();
                          System.out.println("Thank You For Using Kunal Calculator, GOODBYE");
                          System.out.println();
                          System.out.println("Want to Use Again, then Wait 3 Seconds");
                          Thread.sleep(1800);
                          System.out.println();
                          System.out.println();
                          System.out.println();
                          
                          
                      }
                  }
              }
    

Make Sure To Build This in .jar Format and Save the File Name As "JavaCalculator.jar"

You can Use This As Much As You Want Coz This is In A Loop

MacStock Official

Author & Editor

Python Programmer and a Simple Web Developer. Owns a Youtube Channel Named MacStock Tech & Gaming and This Website also Refers to him

0 Comments:

Post a Comment