Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following exercises must be completed before you come to lab. Your instructo

ID: 3675706 • Letter: T

Question

The following exercises must be completed before you come to lab.  Your instructor will check your pre-lab exercises at the beginning of the lab period.  Completion of the pre-lab is worth 10 points of the total 50 points for the lab.

Part 1 – Tracing control structures

Predict the output of the following Repetition Control Structures:

1. number = 1 number Output

LOOP WHILE number < 7

number = number * 2

ADD 2 to number

END WHILE

PRINT “Number is”  number

2. int count = 7; count Output

while (count > 3)

{

   System.out.println(count % 2);

   count--;

}

Value of count when loop is done: _________________

3. int seconds = 5;

for(int i=0; i < seconds; i++)

{

   System.out.println(“Time left: “ + (seconds – i));

}

seconds   i    Output

Part 2

Create a UML class diagram for the Donation class.  The Donation class represent a donation to a non-profit organization.  The donation class will carry the following information:

name of the donor as it appears on the card

credit card number

amount donated

This class will have the following methods:

special constructor that accept value for name and credit card

getters for all fields

setter for the donation amount

a private method that returns the credit card number in the format “************1234” (first 12 digits of the number are masked using “*” then the last 4 digits).

a printSummary method that displays information about the donation.  For the credit card number, it should display the masked value (Which method should be called here?)  Follow sample format below:

Anne Smith

Credit Card: ************1111

Donation Amount: $125.00

Explanation / Answer

1.

Number will be 10 it runs the loops twice but in the second time number will be 10 and aftrer checking it returns false so it comes out from the loop

so value is 10

2.

The Value of count when loop is done is "0" as it satisfies the condition 7>3 and then it performs 7%3 result will be 1 after decrenting to 1 value of count is 0 so 0 is not greather than 3 so the control will come out of loop and it prints the value of count
count=0;

3.

Time left:5

Time left:4

Time left:3

Time left:2

Time left:1

as after this turn it checks 5<5 it returns false and come ourt of loop and prints the above output.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote