CST8116-Lab Ex2 weeek 3 assignment FINAL

docx

School

Algonquin College *

*We aren’t endorsed by this school

Course

8101

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

3

Uploaded by ColonelYakMaster1015

Report
CST8116 Introduction to Computer Programming Lab Exercise 02 Companion File (21S) Part 1 Understand the Problem The problem statement does not mention any user input for the program, just output and processing, so I can pick some sample numbers for testing and will use a pocket calculator for testing pseudocode and flowchart. Sample calculations/methods to look for with similar names in the Java API for class math: powerResult = power(3, 3) // raise 3^4 in other words 3 3 is 3 * 3 * 3 = 27 squareRootResult = squareRoot(49) // should be 7 as 7 x 7 is 49 i.e. solve for 49 roundDownResult = round(6.4) // should round down to 6 roundUpResult = round(2.5) // should round up to 3 ceilingResult = ceiling(4.01) // should round up to value of 5.0 PI // value of PI should be 3.141592654 or longer The program would only need to output some text and the results and my name as author. Part 2 Develop and Describe an Algorithm Pseudocode start declarations num powerResult num squareRootResult num roundDownResult num roundUpResult num ceilingResult powerResult = power(3,3) squareRootResult = squareRoot(49) roundDownResult = round(6.4) roundUpResult = round(2.5) ceilingResult = ceiling(4.01) output "power of 3 raised to 3 is " + powerResult output "square root of 49 is " + squareRootResult output "rounding 6.4 results in " + roundDownResult output "rounding 3.5 results in " + roundUpResult output "ceiling of 4.01 is " + ceilingResult output "PI is " + PI output "program by Sarbjeet singh " stop Flowchart
3 Test Algorithm Test Values Expected Output Actual Output Description 3 3 power of 3raised to 3 is 27 power of 3 raised to 3 is 27 Matches 49 square root of 49 is 7 square root of 49 is 7 Matches 6.4 rounding 6.4 results in 6 rounding 6.4 results in 6 Matches 3.5 rounding 3.5 results in 4 rounding 3.5 results in 4 Matches 4.01 ceiling of 4.01 is 5 ceiling of 4.01 is 5 Matches
PI is 3.141592654 PI is 3.141592654 Matches, (value shown obtained from pocket calculator) Program by Sarbjeet singh Program by Sarbjeet singh Name granted. Appendix: Example of Expected Program Run from a completed program power of 3 raised to 3 is 27.0 square root of 49 is 7.0 rounding 6.4 results in 6.0 rounding 2.5 results in 3.0 ceiling of 4.01 is 5.0 PI is 3.141592653589793 Program by Sarbjeet singh
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help