diff --git a/code-issue-examples/java-pmd/Calculator.java b/code-issue-examples/java-pmd/Calculator.java new file mode 100644 index 0000000..d809c2a --- /dev/null +++ b/code-issue-examples/java-pmd/Calculator.java @@ -0,0 +1,64 @@ +import java.util.Scanner; + +public class Calculator { + + // Method to perform addition + public static double add(double num1, double num2) { + return num1 + num2; + } + + // Method to perform subtraction + public static double subtract(double num1, double num2) { + return num1 - num2; + } + + // Method to perform multiplication + public static double multiply(double num1, double num2) { + return num1 * num2; + } + + // Method to perform division + public static double divide(double num1, double num2) { + if (num2 == 0) { + System.out.println("Error! Division by zero is not allowed."); + return 0; + } + return num1 / num2; + } + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + System.out.println("Welcome to the Calculator!"); + System.out.println("Enter first number: "); + double num1 = scanner.nextDouble(); + + System.out.println("Enter second number: "); + double num2 = scanner.nextDouble(); + + System.out.println("Choose operation: +, -, *, /"); + char operation = scanner.next().charAt(0); + + double result = 0; + + switch (operation) { + case '+': + result = add(num1, num2); + break; + case '-': + result = subtract(num1, num2); + break; + case '*': + result = multiply(num1, num2); + break; + case '/': + result = divide(num1, num2); + break; + default: + System.out.println("Invalid operation!"); + return; + } + + System.out.println("The result is: " + result); + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 55f0f1a..e2346a9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,7 +1,6 @@ rootProject.name = "codety-scanner" include 'code-issue-examples' -include 'image' include 'scanner-common' include 'scanner' include 'analyzer-codety'