Can you create diagrams using Visual Paradigm or equivalent UML software to create Class and  Object Diagrams showing their relationship using the program that I uploaded?

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question

Can you create diagrams using Visual Paradigm or equivalent UML software to create Class and  Object Diagrams showing their relationship using the program that I uploaded?

Main.java x
import java. lang.*;
public class Main{ I
2
//Add various methods to perform different arithme tic operations
public int add(int a, int b){
return a * b;
7
public int sub(int a, int b) {
return a - b;
10
11
public int mul(int a, int b) {
return a * b;
12
13
}
public int div(int a, int b){
if(b == 0){
System.out.println("Dividing value can not be zero! ") ;
14
15
16
17
return 0;
18
19
else{
20
return a/ b;
21
22
}
23
24
public int exp(int base, int expo)
{
25
26
int pow = 1;
//increase the value of i for each iteration
27
for (int i = 1; i <= expo; i++)
//power calculation
28
29
30
pow = pow * base;
//returns power
31
32
return po;
}
33
34
public double cuberoot (int a) {
return Math.cbrt(a);
35
36
37
38
39
// Declare main class to create object of the class and call its methods
40
public static oid main(String[] args){
//Create object or the Cal class
Main c = new Main();
41
42
43
// Call one by one methods of the class and print the results
System.out.println("Addition: "+c.add(5,10));
System.out.println("Subtraction: "+c.sub(10,5));
System.out.println("Multiplication : "+c.mul(5, 19));
System.out.println("Division: "+c.div(10,5));
System.out.println("Exponent: "+c.exp(7,6));
System.out.println("Cube root: "+c.cuberoot (1090));
44
45
46
47
48
49
50
51
52
Transcribed Image Text:Main.java x import java. lang.*; public class Main{ I 2 //Add various methods to perform different arithme tic operations public int add(int a, int b){ return a * b; 7 public int sub(int a, int b) { return a - b; 10 11 public int mul(int a, int b) { return a * b; 12 13 } public int div(int a, int b){ if(b == 0){ System.out.println("Dividing value can not be zero! ") ; 14 15 16 17 return 0; 18 19 else{ 20 return a/ b; 21 22 } 23 24 public int exp(int base, int expo) { 25 26 int pow = 1; //increase the value of i for each iteration 27 for (int i = 1; i <= expo; i++) //power calculation 28 29 30 pow = pow * base; //returns power 31 32 return po; } 33 34 public double cuberoot (int a) { return Math.cbrt(a); 35 36 37 38 39 // Declare main class to create object of the class and call its methods 40 public static oid main(String[] args){ //Create object or the Cal class Main c = new Main(); 41 42 43 // Call one by one methods of the class and print the results System.out.println("Addition: "+c.add(5,10)); System.out.println("Subtraction: "+c.sub(10,5)); System.out.println("Multiplication : "+c.mul(5, 19)); System.out.println("Division: "+c.div(10,5)); System.out.println("Exponent: "+c.exp(7,6)); System.out.println("Cube root: "+c.cuberoot (1090)); 44 45 46 47 48 49 50 51 52
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT