├── dhanu.png
├── SimpleCalculator.java
└── README.md
/dhanu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vinaykumarmahato/Simple-Calculator-Using-java/HEAD/dhanu.png
--------------------------------------------------------------------------------
/SimpleCalculator.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 |
3 | public class SimpleCalculator {
4 | public static void main(String[] args) {
5 | Scanner scanner = new Scanner(System.in);
6 |
7 | System.out.println("Welcome to the Simple Calculator!");
8 |
9 | System.out.print("Enter the first number: ");
10 | double num1 = scanner.nextDouble();
11 |
12 | System.out.print("Enter the second number: ");
13 | double num2 = scanner.nextDouble();
14 |
15 | System.out.println("Select the operation:");
16 | System.out.println("1. Addition (+)");
17 | System.out.println("2. Subtraction (-)");
18 | System.out.println("3. Multiplication (*)");
19 | System.out.println("4. Division (/)");
20 |
21 | System.out.print("Enter your choice (1-4): ");
22 | int choice = scanner.nextInt();
23 |
24 | double result = 0.0;
25 | String operation = "";
26 |
27 | switch (choice) {
28 | case 1:
29 | result = num1 + num2;
30 | operation = "+";
31 | break;
32 | case 2:
33 | result = num1 - num2;
34 | operation = "-";
35 | break;
36 | case 3:
37 | result = num1 * num2;
38 | operation = "*";
39 | break;
40 | case 4:
41 | if (num2 != 0) {
42 | result = num1 / num2;
43 | operation = "/";
44 | } else {
45 | System.out.println("Error: Division by zero is not allowed.");
46 | return;
47 | }
48 | break;
49 | default:
50 | System.out.println("Error: Invalid choice.");
51 | return;
52 | }
53 |
54 | System.out.println("Result: " + num1 + " " + operation + " " + num2 + " = " + result);
55 |
56 | scanner.close();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Simple Calculator Using Java
2 |
3 | This is a simple calculator program written in Java that can perform basic arithmetic operations such as addition, subtraction, multiplication, and division.
4 |
5 | ## Usage
6 |
7 | To use the calculator, simply run the `Calculator.java` file in your preferred IDE or from the command line. The program will prompt you to enter two numbers and an operator (+, -, *, /) to perform the desired operation.
8 |
9 |
10 | The program will continue to prompt you for input until you enter "exit" as the operator.
11 |
12 |
13 | ## Repository Structure
14 |
15 | The repository is organized as follows:
16 |
17 | - src/
18 | - Calculator.java
19 |
20 | ### Contributing
21 | Contributions are welcome! If you find any bugs or have suggestions for improvement, please open an issue or submit a pull request.
22 |
23 |
24 |
25 | ⚡Subscribe on LinkedIn🌱🌱🌱
26 | ⚡Subscribe on YouTube🌱🌱🌱
27 |
28 | ⚡Follow me on Instagram🌱🌱🌱
29 |
30 |
31 | 
32 |
33 |
34 |
35 |
36 | # 💫 About Me:
37 | 🔭 I’m currently working on content creation and freelancing also I'm doing internship by pw Skills in the field of java development
👯 I’m looking to collaborate on Back-End development as well as content creation
🤝 I’m looking for help with developing many software that can find the user easily
🌱 I’m currently learning java DSA system Design by pw skills ( Physics wallah )
💬 Ask me about - java, HTML, CSS, JAVASCRIPT | DBMS | MongoDB | JDBC | DSA | System Design | Spring Boot | Spring Rest | PHOTOGRAPHY & EDITER |
⚡ Fun fact - coding lover , singing , teaching
38 |
39 |
40 | ## 🌐 Socials:
41 | [](https://facebook.com/https://facebook.com/groups/602312964862870/) [](https://instagram.com/https://www.instagram.com/invites/contact/?i=td1e6t78x4bp&utm_content=oeyjr77) [](https://linkedin.com/in/https://www.linkedin.com/in/vinay-kumar860964) [](https://twitter.com/https://twitter.com/ADV_India_coder) [](https://youtube.com/@https://youtube.com/@advindiancoder)
42 |
43 | # 💻 Tech Stack:
44 |                     
45 | # 📊 GitHub Stats:
46 | 
47 | 
48 | 
49 |
50 | ## 🏆 GitHub Trophies
51 | 
52 |
53 | ## 🐦 Latest Tweet
54 | [](https://github.com/VishwaGauravIn/github-twitter-card-embed)
55 |
56 | ### ✍️ Random Vinay kumar java developer Quotes
57 | 
58 |
59 | ### 🔝 Top Contributed Repo
60 | 
61 |
62 | ### 😂 Random vinay kumar java developer Meme
63 |
64 |
65 | ---
66 | [](https://visitcount.itsvg.in)
67 |
68 |
69 |
--------------------------------------------------------------------------------