We have the following code which should calculate the


Assignment -

This assignment has 2 parts. The first part focuses on debug using processing. The second part focused on using Java to deal with some simple problems.

Part 1 - Debug

We have the following code which should calculate the factorial of the integer n and display the result on the canvas.

size(200, 200);

int n = 5;

int factorial = 1;

for(int i = 0; i < n; i++){

factorial = factorial * i;

}

text("factorial", 100, 100);

There are a few errors with this code, and it needs fixing. We want you to copy the above code into a new work in the Workspace and use line tracing to find the errors.

Once you are done you should run the program with the following test cases.

Input (value of n)

Expected Output (printed to the canvas)

0

1

1

1

3

6

7

5040

Part 2 - Withdraw Money from ATM

We wish to develop a ATM class that will test whether or not a particular number, representing an amount of cash, can be represented as a combination of $20 and/or $50 notes.

In your ATM class, you should have one function named run. This function will take a number which represent an amount of cash as input, and a string as output. The string should either be "Here is X $20 notes and Y $50 notes." when the amount can be dispensed using X $20 notes and Y $50 notes or "Sorry, the value you input cannot be withdrawed.". Your program should be able to calculate the value for X and Y.

If there are multiple ways to dispense an amount, please use the composition with the fewest number of bills.

Attachment:- Assignment File.rar

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: We have the following code which should calculate the
Reference No:- TGS02706218

Expected delivery within 24 Hours