Thank u so much i have got the answers for 456 Still 123 CS1

Thank u so much i have got the answers for 4/5/6 Still 1/2/3/

CS141 programming II (java)

Assignment 2

Chapter 12 – OOD

Chapter 13 - Recursion

Assignment 2 worth 5 points, Due on 26/10/2016. Will deduct 1 point for each day late. Copying each other work will result in giving 0 to both.

Q1: Briefly define the term Waterfall model? And list the phases of the development process in order they are done? (5 points)

Q2: Fill in the table below by drawing the correct arrow that represent the relationship between classes? And Indicate Type of relationship: if it is an “IS-A” or “HAS-A”, or “USES” relationship if applicable(5 points)

Relationship

Draw

Type of relationship

Inheritance

Interface Implementation

Aggregation

Dependency

Q3: Given Question 5 from the previous Assignment1.   ( 10 points )

Draw the correct UML diagram to represent the relationships between all classes.

Add an Interface called Measurable and indicate in the diagram that the Employee class implements Measurable interface.

For each class in your diagram do the CRC card for each to indicate responsibilities and collaborators.

Measurable

             

Q4: Write and run the java program that computes the Factorial of a given number using a Recursive method.   ( 20 points )

Submit your program files as .java file that can be run. And submit in the document sample run for example given the value 4 the factorial is 24

Q5. What is the advantage and disadvantage of using recursion? ( 5 points )

Q6. Briefly explain what is infinite recursion, and what causes it to happen? ( 5 points )

Relationship

Draw

Type of relationship

Inheritance

Interface Implementation

Aggregation

Dependency

Solution

4.The java program that computes the Factorial of a given number using a Recursive method :-

class Factorial
{
public static void main(String[] args)
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ;
System.out.println(\"Enter Number:\") ;
int n = Integer.parseInt(br.readLine()) ;

int fact = factorial(n) ;
System.out.println(\"The factorial value of 4 is \" + fact) ;
}

public static int factorial(int n)
{
if (n == 0)
{
return 1 ;
}
else
{
return n * factorial(n - 1) ;
}
}
}

5.The Advantages of Recursion :-

* Recursion will reduce the length of the source code.

The Disadvantages of Recursion :-

* Recursion may consume large amounts of memory.

6. Infinite Recursion :-

* Forget to stop recursion causes Infinite recursion to happen.

Thank u so much i have got the answers for 4/5/6 Still 1/2/3/ CS141 programming II (java) Assignment 2 Chapter 12 – OOD Chapter 13 - Recursion Assignment 2 wort
Thank u so much i have got the answers for 4/5/6 Still 1/2/3/ CS141 programming II (java) Assignment 2 Chapter 12 – OOD Chapter 13 - Recursion Assignment 2 wort

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site