From 98831871d8d305ef04a216eb2cb3dd6604c4c9c8 Mon Sep 17 00:00:00 2001 From: pranaykalg Date: Sat, 9 Mar 2024 11:31:57 +0530 Subject: [PATCH] comments --- .../mes/casetools/lab3/bca_2205121/cal.class | Bin 0 -> 1457 bytes .../mes/casetools/lab3/bca_2205121/cal.java | 74 ++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 lab3/src/main/java/mes/casetools/lab3/bca_2205121/cal.class create mode 100644 lab3/src/main/java/mes/casetools/lab3/bca_2205121/cal.java diff --git a/lab3/src/main/java/mes/casetools/lab3/bca_2205121/cal.class b/lab3/src/main/java/mes/casetools/lab3/bca_2205121/cal.class new file mode 100644 index 0000000000000000000000000000000000000000..dde60dfaa48a2efbe895a42db63b6b024796b730 GIT binary patch literal 1457 zcmaJ=ZEq7t5Pmjse9q+(QseNR#H1mdQ@|v=V**L+gai^mG775tp<3Uq!s7F-lLul!3y!Av=OBH5dGfb6v7%H9j z<$?4?zShaV6D?)Kf@30$6T;m&a#PhU8Sa+~d+F7A;zeJ2HJ2PlaS}NTQw~ny^f7|f zPNYSHc&RqgoJ!nDReV9dGKDl1dCrNIwHo+U7=qqKRS`dij9YOWMS15Z;fI8sM#_+ zP<2sEdY;sClaf`f4#V&LQ_%w^PPcgI2O^r^QL5fjd6vNj!$h^$sYBgkh97p59!Z*$L-jV@tuUiPb%_58*yaw4Wo~10uB^ua$V+jMptZA-hesr`W}Foc#(` CS3k7? literal 0 HcmV?d00001 diff --git a/lab3/src/main/java/mes/casetools/lab3/bca_2205121/cal.java b/lab3/src/main/java/mes/casetools/lab3/bca_2205121/cal.java new file mode 100644 index 0000000..263948e --- /dev/null +++ b/lab3/src/main/java/mes/casetools/lab3/bca_2205121/cal.java @@ -0,0 +1,74 @@ +package mes.casetools.lab3.bca_2205121; +/** + * This class represents a simple calculator that can perform + * basic arithmetic operations like addition, subtraction, + * multiplication, and division. + * + * @author Your Name + * @version 1.0 + * @since 2023-03-09 + */ +public class cal { + /** + * Adds two numbers together. + * + * @param a the first number + * @param b the second number + * @return the sum of the two numbers + */ + public static double add(double a, double b) { + return a + b; + } + + /** + * Subtracts the second number from the first. + * + * @param a the first number + * @param b the second number + * @return the difference between the two numbers + */ + public static double subtract(double a, double b) { + return a - b; + } + + /** + * Multiplies two numbers together. + * + * @param a the first number + * @param b the second number + * @return the product of the two numbers + */ + public static double multiply(double a, double b) { + return a * b; + } + + /** + * Divides the first number by the second. + * + * @param a the first number (dividend) + * @param b the second number (divisor) + * @return the quotient of the two numbers + * @throws ArithmeticException if the divisor is zero + */ + public static double divide(double a, double b) throws ArithmeticException { + if (b == 0) { + throw new ArithmeticException("Cannot divide by zero"); + } + return a / b; + } + + /** + * The main method to test the calculator. + * + * @param args command-line arguments (not used) + */ + public static void main(String[] args) { + double num1 = 10.0; + double num2 = 5.0; + + System.out.println("Addition: " + add(num1, num2)); + System.out.println("Subtraction: " + subtract(num1, num2)); + System.out.println("Multiplication: " + multiply(num1, num2)); + System.out.println("Division: " + divide(num1, num2)); + } +}