-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Writing first Java class using IntelliJ
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
public class Demo { | ||
|
||
public static void main(String[] args) { | ||
System.out.println("Hello Madan"); | ||
} | ||
|
||
|
||
/** | ||
* Adds two numbers | ||
* @param a the first number | ||
* @param b the second number | ||
* @return the sum of the two numbers | ||
*/ | ||
public static int add(int a, int b) { | ||
System.out.println("Sum: " + (a+b)); | ||
return a + b; | ||
} | ||
|
||
/** | ||
* Subtracts two numbers | ||
* @param a the first number | ||
* @param b the second number | ||
* @return the difference of the two numbers | ||
*/ | ||
public static int subtract(int a, int b) { | ||
System.out.println("Difference: " + (a-b)); | ||
return a - b; | ||
} | ||
|
||
/** | ||
* Multiplies two numbers | ||
* @param a the first number | ||
* @param b the second number | ||
* @return the product of the two numbers | ||
*/ | ||
public static int multiply(int a, int b) { | ||
System.out.println("Product: " + (a*b)); | ||
return a * b; | ||
} | ||
|
||
/** | ||
* Divides two numbers | ||
* @param a the first number | ||
* @param b the second number | ||
* @return the quotient of the two numbers | ||
*/ | ||
public static double divide(int a, int b) { | ||
System.out.println("Quotient: " + (a/b)); | ||
return (double)a / b; | ||
} | ||
|
||
|
||
} |