Skip to content

Commit 1784572

Browse files
committed
first java committee
1 parent 860c8d6 commit 1784572

32 files changed

Lines changed: 1102 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
# Auto detect text files and perform LF normalization
3+
* text=auto
4+
5+
# Java files
6+
*.java text
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
# Compiled class files
3+
*.class
4+
5+
# Logs
6+
*.log
7+
8+
# OS generated files
9+
.DS_Store
10+
Thumbs.db
11+
12+
# IDE files
13+
.idea/
14+
.vscode/
15+
*.iml
16+
17+
# Build directories
18+
bin/
19+
out/
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package Calculator;
2+
3+
import java.util.Scanner;
4+
5+
public class Main {
6+
public static void main(String[] args) {
7+
8+
// CALCULATOR
9+
10+
Scanner scanner = new Scanner(System.in);
11+
12+
double num1;
13+
char operator;
14+
double num2;
15+
double result = 0;
16+
boolean validOperation = true;
17+
18+
System.out.print("Enter the first number: ");
19+
num1 = scanner.nextDouble();
20+
21+
System.out.print("Enter the operation {+, -, *, /, ^): ");
22+
operator = scanner.next().charAt(0);
23+
24+
System.out.print("Enter the secound number: ");
25+
num2 = scanner.nextDouble();
26+
27+
switch (operator) {
28+
case '+' -> result = num1 + num2;
29+
case '-' -> result = num1 - num2;
30+
case '*' -> result = num1 * num2;
31+
case '^' -> result = Math.pow(num1, num2);
32+
case '/' -> {
33+
if(num2 == 0){
34+
System.out.println("Number must be a greater than zero");
35+
validOperation = false;
36+
}
37+
else{
38+
System.out.println(result = num1 / num2);
39+
}
40+
}
41+
default -> {
42+
System.out.println("Invalid operator!");
43+
validOperation = false;
44+
}
45+
}
46+
if(validOperation){
47+
System.out.println(result);
48+
}
49+
scanner.close();
50+
}
51+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Calculator
2+
3+
## Description
4+
5+
A simple Java calculator application that performs basic arithmetic operations such as addition, subtraction, multiplication, and division.
6+
7+
---
8+
9+
## Features
10+
11+
- Console-based Java application
12+
- Clean and beginner-friendly logic
13+
- Demonstrates core Java fundamentals
14+
- Structured using packages
15+
16+
---
17+
18+
## Technologies Used
19+
20+
- Java
21+
- OOP Concepts
22+
- Console Input/Output
23+
24+
---
25+
26+
## How to Compile and Run
27+
28+
Make sure you are in the project root directory.
29+
30+
### Compile
31+
```
32+
javac Calculator\Main.java
33+
```
34+
35+
### Run
36+
```
37+
java Calculator.Main
38+
```
39+
40+
---
41+
42+
## Author
43+
44+
Dhruv
45+
46+
---
47+
48+
## Working
49+
50+
javac Calculator\Main.java
51+
java Calculator.Main
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
# Auto detect text files and perform LF normalization
3+
* text=auto
4+
5+
# Java files
6+
*.java text
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
# Compiled class files
3+
*.class
4+
5+
# Logs
6+
*.log
7+
8+
# OS generated files
9+
.DS_Store
10+
Thumbs.db
11+
12+
# IDE files
13+
.idea/
14+
.vscode/
15+
*.iml
16+
17+
# Build directories
18+
bin/
19+
out/
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package CompoundInterestCalculataor;
2+
import java.util.Scanner;
3+
4+
public class Main {
5+
public static void main(String[] args) {
6+
7+
// Compound Interest Calculator
8+
Scanner scanner = new Scanner(System.in);
9+
double principal;
10+
double rate;
11+
int timeCompound;
12+
int years;
13+
double amount;
14+
15+
System.out.print("Enter the principal amount: ");
16+
principal = scanner.nextDouble();
17+
18+
System.out.print("Enter the intrest rate (in %): ");
19+
rate = scanner.nextDouble() / 100;
20+
21+
System.out.print("Enter the number of times compounded per year: ");
22+
timeCompound = scanner.nextInt();
23+
24+
System.out.print("Enter the number of year(s) ");
25+
years = scanner.nextInt();
26+
27+
amount = principal * Math.pow(1 + rate / timeCompound , timeCompound * years);
28+
System.out.printf("The amount after %d years is $%.2f" , years , amount);
29+
30+
scanner.close();
31+
}
32+
33+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# CompoundInterestCalculataor
2+
3+
## Description
4+
5+
A Java program that calculates compound interest based on principal amount, interest rate, and time period.
6+
7+
---
8+
9+
## Features
10+
11+
- Console-based Java application
12+
- Clean and beginner-friendly logic
13+
- Demonstrates core Java fundamentals
14+
- Structured using packages
15+
16+
---
17+
18+
## Technologies Used
19+
20+
- Java
21+
- OOP Concepts
22+
- Console Input/Output
23+
24+
---
25+
26+
## How to Compile and Run
27+
28+
Make sure you are in the project root directory.
29+
30+
### Compile
31+
```
32+
javac CompoundInterestCalculataor\Main.java
33+
```
34+
35+
### Run
36+
```
37+
java CompoundInterestCalculataor.Main
38+
```
39+
40+
---
41+
42+
## Author
43+
44+
Dhruv
45+
46+
---
47+
48+
## Working
49+
50+
javac CompoundInterestCalculataor\Main.java
51+
java CompoundInterestCalculataor.Main
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
# Auto detect text files and perform LF normalization
3+
* text=auto
4+
5+
# Java files
6+
*.java text
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
# Compiled class files
3+
*.class
4+
5+
# Logs
6+
*.log
7+
8+
# OS generated files
9+
.DS_Store
10+
Thumbs.db
11+
12+
# IDE files
13+
.idea/
14+
.vscode/
15+
*.iml
16+
17+
# Build directories
18+
bin/
19+
out/

0 commit comments

Comments
 (0)