You are on page 1of 5

AP Computer Science Principles

16 March 2023

PDE – Calculator Time Questions

4. The overall purpose of the program is serving the user with a calculator that can find a

maximum of 5 numbers, sum it and also calculate perimeter and area of a rectangle.

5. The functionality involves alien asking the astronaut the maximum of 5 numbers chosen

by the user and the sum while requiring the perimeter and area of a rectangle whose length and

width are also user input. The astronaut answers accurately and the alien exits.

6. The user inputs whole numbers into a GUI box which the human finds the maximum and

sum of. The user also provides the length and width for the rectangle using whole number input

into another GUI box.

7. The astronaut says maximum number as 334 and sum as 417. He also describes the

perimeter as 278 and area of rectangle as 4590.

Count for Reporting Category 1 is 140 words.

8.

9.
Ragavan 2

10. The data contained in the array challengeHuman is populated through user input where the

user provides the 5 values. Once populated, the array contains all of the 5 values in the order

that the user presented. The contents of challengeHuman are used in the program to find the

maximum and the sum of those numbers. In order to find the maximum, the alien asks the

human the maximum number in challengeHuman, and the human responds by providing that

number. Next, the alien reads out the contents of challengeHuman one by one also in the order

that the user provided the content. Then the human quickly finds the sum of the content in array

challengeHuman. In total, the data in challengeHuman is given as whole number input from the

user which contributes to the story by allowing the human to find the maximum and the sum of

that array.

Count for Reporting Category 2 is 149 words.

11.

12. Without challengeHuman array, 5 separate variables must be declared in the program and

their values must be requested from the user. This creates inefficient and exhaustive code.

However, when an array is used in a while loop with an incrementing index the code would be

more efficient.

Count for Reporting Category 3 is 48 words

14.
Ragavan 3

15.

16. The method maxFunction is needed to answer the alien’s first question which asks for the

maximum number in challengeHuman array.

17. The method maxFunction uses whole number user input and finds the maximum of the 5

numbers. This is called in myFirstMethod for the human to say the correct answer.

Count for Reporting Category 4 is 49 words. 19.

20.
Ragavan 4

21.

22.

First, create maxFunction as a function for returning whole numbers and declare a whole

number array as a parameter named funArrayMax which should be set equal to a whole number

array in myFirstMethod. Declare a whole number variable funMax and initialize to zeroth index

of funArrayMax. Declare a whole number variable funMaxIndex and initialize to 1. Drag a

while loop. The loop should continue if funMaxIndex is less than funArrayMax’s length. Into

the while loop, drag an if-else bracket. The condition of truth should be if funMax is less than

funArrayMax [funMaxIndex]. Under the if section assign funArrayMax [funMaxIndex] to

funMax. Else the biped should think “Let me think...”. Concatenate the text strings and variables

in this manner: Let the biped think “Is it” + funMax + “?” + “Could it be” +

funArrayMax[funMaxIndex] + “?” + “I need some more time.” Increment funMaxIndez by 1

and return funMax.

Count for Reporting Category 5 is 149 words


24.
Ragavan 5

25. In maxFunction, the funMax variable is used in the truth condition which is compared to

the contents of funArrayMax. The parameter involves funArrayMax which is used to pass the

contents of challengeHuman into this function, and funMaxIndex is used to move through the

indices of the array.

26.

27. In maxFunction, in the false selection, the funMax variable is concatenated with the

biped’s think procedure to generate some interest when answering.

28. In maxFunction, the condition of truth being tested is whether funMax is lower than the

value of current array element, if true the current array value is moved to funMax.

29. In maxFunction, the false condition is whether funMax is not lower than the value of

current array element, which if false makes the biped think about the possible max numbers.

30. In maxFunction, the result of the condition of truth is the value of funMax holds the

maximum number 334 from the inputted 5 numbers.

31. In maxFunction, the result of the false condition is the biped saying “Let me think” and

also the biped wondering “Is it 45 ? Could it be 1? I need some more time.”

You might also like