Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package solution;
- import java.io.*;
- import java.util.*;
- import java.text.*;
- import java.math.*;
- import java.util.regex.*;
- import java.lang.reflect.*;
- import java.security.Permission;
- class Calculate
- {
- class Output{
- public void display(double volume)
- {
- System.out.printf("%.3f\n",volume);
- }
- }
- Output output;
- Scanner sc;
- public Calculate() {
- output = new Output();
- sc = new Scanner(System.in);
- }
- public int get_int_val() {
- int a = sc.nextInt();
- if(a<=0){throw new NumberFormatException("All the values must be positive");}
- return a;
- }
- public double get_double_val() {
- double a = sc.nextDouble();
- if(a<=0){throw new NumberFormatException("All the values must be positive");}
- return a;
- }
- public static Get_Vol do_calc() {
- return new Get_Vol();
- }
- }
- class Get_Vol extends Calculate {
- double get_volume(int val) throws IOException {
- return (val*val*val);
- }
- double get_volume(int val, int val2, int val3) throws IOException {
- return val*val2*val3;
- }
- double get_volume(double val) throws IOException {
- return Math.PI*(val*val*val) * (2.0/3.0);
- }
- double get_volume(double val, double val2)throws IOException {
- return Math.PI*(val*val)*val2;
- }
- }
Add Comment
Please, Sign In to add comment