Draw a UML class diagram to show the design of your program. Clearly show the at
ID: 3648820 • Letter: D
Question
Draw a UML class diagram to show the design of your program. Clearly show the attributes and the methods for each of the classes in your program. Also show the associations between the classes, if applicable.My program code is
import java.util.*;
class main{
public static void main(String args[])
{int n1,n2;
Scanner in=new Scanner(System.in);
System.out.print("Enter the starting number: ");
n1=in.nextInt();
System.out.print("Enter the ending number: ");
n2=in.nextInt();
System.out.println("The sum of the numbers from "+n1+" to "+n2+" is "+sum(n1,n2));
}
public static int sum(int n1, int n2)
{int i,sum=0,start,stop;
start=n2;
stop=n1;
if(n1<n2)
{start=n1;
stop=n2;
}
for(i=start;i<=stop;i++)
sum+=i;
return sum;
}
}
Explanation / Answer
A Unified Modeling Language (UML) class diagram is used to identify and describe the classes that will be created when implementing an application. You can think of a class as a person or thing that plays a role in an application. A class often has data, which is represented by attributes. A class also has behaviors, which are represented by methods. Classes can also be related to other classes. For example, a class might inherit from a more general class, a class might contain another class, or a class might use the methods of different class. Let
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.