Skip to content

Commit 4e29d5a

Browse files
committed
Writing first Java class using IntelliJ
1 parent fe70d48 commit 4e29d5a

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

section3/HelloWorld/src/Demo.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
public class Demo {
2+
3+
public static void main(String[] args) {
4+
System.out.println("Hello Madan");
5+
}
6+
7+
8+
/**
9+
* Adds two numbers
10+
* @param a the first number
11+
* @param b the second number
12+
* @return the sum of the two numbers
13+
*/
14+
public static int add(int a, int b) {
15+
System.out.println("Sum: " + (a+b));
16+
return a + b;
17+
}
18+
19+
/**
20+
* Subtracts two numbers
21+
* @param a the first number
22+
* @param b the second number
23+
* @return the difference of the two numbers
24+
*/
25+
public static int subtract(int a, int b) {
26+
System.out.println("Difference: " + (a-b));
27+
return a - b;
28+
}
29+
30+
/**
31+
* Multiplies two numbers
32+
* @param a the first number
33+
* @param b the second number
34+
* @return the product of the two numbers
35+
*/
36+
public static int multiply(int a, int b) {
37+
System.out.println("Product: " + (a*b));
38+
return a * b;
39+
}
40+
41+
/**
42+
* Divides two numbers
43+
* @param a the first number
44+
* @param b the second number
45+
* @return the quotient of the two numbers
46+
*/
47+
public static double divide(int a, int b) {
48+
System.out.println("Quotient: " + (a/b));
49+
return (double)a / b;
50+
}
51+
52+
53+
}

0 commit comments

Comments
 (0)