Java Exp7
Java Exp7
Java Exp7
Roll No: 10
Experiment 7
Q1. Develop a mathematical package for Statistical operations like factorial, cube. Create
a sub package in the math package -convert. In “convert” package provide classes to
convert decimal to octal, binary, hex and vice-versa. Develop application program to use
this package
MathApp/
├── math/
│ ├── Statistical.java
│ └── convert/
│ └── DecimalConverter.java
└── App.java
Statistical.java:
package math;
import math.Statistical;
import math.convert.DecimalConverter;
import java.util.Scanner;
scanner.close();
}
}
OUTPUT:
OperationApp/
├── Operation/
│ └── Addition.java
└── Test.java
Addition.java
package Operation;
Test.java
import Operation.Addition;
import java.util.Scanner;
scanner.close();
}
}
OUTPUT
OperationsApp/
├── Operations/
│ ├── Addition.java
│ ├── Subtraction.java
│ ├── Multiply.java
│ └── Divide.java
└── Test.java
Addition.java
package Operations;
Multiply.java
package Operations;
package Operations;
Test.java
import Operations.Addition;
import Operations.Subtraction;
import Operations.Multiply;
import Operations.Divide;
import java.util.Scanner;
try {
System.out.println("Division: " + divide.divide(num1, num2));
} catch (ArithmeticException e) {
System.out.println("Error: " + e.getMessage());
}
scanner.close();
}
}
OUTPUT
PS D:\JAVA_PROGRAMMING> javac Test.java
Operations/Addition.java Operations/Subtraction.java Operations/Multiply.java
Operations/Divide.java