Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Principles of Computer Science Assignment-

Background

In this assignment, you'll be working with two related but distinct problem domains. Read this material carefully.

Question 1 -

Purpose: To build a program and test it, starting with a design document. To get warmed up with Python, in case you are using it for the first time. To establish the standards of documentation and testing for CMPT 145.

Degree of Difficulty: Moderate. Don't leave this to the last minute.

In this question you will implement a program that does the following:

  • It asks the user for a sequence of 9 numbers. The order of the numbers is important, as the rows of the grid use this order.
  • It checks whether the sequence of numbers is a magic square or not. Your program should display the message "yes" if it's magic, or "no" if it's not.

It's very important to point out that you are not being asked to construct a magic square; only to check if a square is magic or not.

We've given you a design document called MagicSquareDD.txt (available on Moodle), which is the result of a fairly careful design process. It describes a collection of algorithms which, when used together, should solve the problem. You must implement the program according to the design in this document. There will be some very small decisions you still have to make about the implementation. Every "Algorithm" in the design document will be a procedure or function written in Python. Function names should be very strongly similar to the given design, if not identical.

It's a top-down design, and algorithms are presented in the order they were designed. In a top-down document, it is common for a function to be called before the algorithm is given; this is the opposite of the order that Python uses. You should not implement the program "top-down." A good rule of thumb is this: "Design top-down. Implement bottom-up." It's not a hard and fast rule, but it's a good guide.

For every function in the program, you are to write testing for it. Your approach should be as follows, for each function you implement:

1. Read the design specification for the function.

2. Write a trivial Python function that does nothing, but has the correct name, the appropriate parameters, and a return value that's appropriate.

The function has the right parameters, and returns a value of the right kind, but doesn't really do what it is supposed to do, yet. Your function could also return None, or some other value.

3. Design a number of test cases for the function based on the information in the design document. Yes, do that before you implement the function! Implement the test cases in a Python file named a1q1_testing.py.

4. Run your test program. Some, if not all, of the tests should fail, because you haven't implemented the function yet. That's exactly where you want to be.

5. Implement the function carefully. Then run the test program. Debug this function as necessary until all the tests pass.

6. If you taken the time to design your tests carefully, you can go on to the next function assured that your implementation of the current function is completely correct. Do not disable the testing of any function. Every test for every function you've written should be tried every time you add a new function.

That way you know if you changed something for the worse.

Because everyone is starting with the same design document, every program will have a high degree of similarity. The value of this assignment is the experience you gain from doing it. Hopefully, you will agree that a good design makes implementation fairly easy. Hopefully, you will see the earmarks of a thorough (if not high quality) design.

Question 2 -

Purpose: To reflect on the work of programming for Question 1.

Degree of Difficulty: Easy.

Answer the following questions about your experience implementing the program in Question 1. You may use point form, and informal language. Just comment on your perceptions; you do not have to give really deep answers. Be brief. These are not deep questions; a couple of sentences or so ought to do it.

1. Comment on your program's correctness. How confident are you that your program (or the functions that you completed) is correct? What new information (in addition to your current level of testing) would raise your confidence? How likely is it that your program might be incorrect in a way you do not currently recognize?

2. Comment on your program's efficiency. How confident are you that your program is reasonably efficient? What facts or concepts did you use to estimate or quantify your program's efficiency?

3. Comment on your program's adaptability. For example, what if Assignment 2 asked you to write a program to check whether a 5 x 5 square was magic (bigger square with a larger sum, using the numbers 1 through 25)? How hard would it be to take your work in A1Q1, and revise it to handle squares of any size?

4. Comment on your program's robustness. Can you identify places where your program might behave badly, even though you've done your best to make it correct? You do not have to fix anything you mention here; it's just good to be aware.

5. How much time did you spend completing this assignment? If you had to solve this problem without the given design document, how much longer (or shorter) do you think it would have taken you to complete, start to finish? Would you have been as con dent in your program's correctness?

Question 3 -

Purpose: To build a program and test it, starting without a design document. This is an exercise to contrast with Question 1.

Degree of Difficulty: Moderate. Don't leave this to the last minute.

In this question you will implement a program that checks whether a N x N square of numbers is a Latin Square or not (see the Background section for the definition). Your program should work by reading input from the console, and sending an answer to the console, as in the following example:

  • It reads a number N on a line by itself. This will be the order of a Latin square. The order must be a positive integer, e.g., N > 0.
  • It reads N lines of N of numbers, i.e., it reads console input for a square of numbers.
  • It checks whether the sequence of numbers is a Latin square or not. Your program should display the message "yes" if it satisfies the above criteria, or "no" if it does not.

Question 4 -

Purpose: To reflect on the work of programming for Question 3.

Degree of Difficulty: Easy.

Answer the following questions about your experience implementing the program in Question 3. You may use point form, and informal language. Just comment on your perceptions; you do not have to give really deep answers. Be brief. These are not deep questions; a couple of sentences or so ought to do it.

1. Comment on your program's correctness. How confident are you that your program (or the functions that you completed) is correct?

2. Comment on your program's efficiency. How confident are you that your program is reasonably efficient?

3. Comment on your program's reusability. For example, did you re-use any code from a different project (maybe Q1)? How easy would it be to re-use any part of your program for another task?

4. Comment on your program's robustness. Can you identify places where your program might behave badly, even though you've done your best to make it correct? You do not have to fix anything you mention here.

5. How much time did you spend completing this question? Compare the time you spent on Q3 with the time you spent on Q1.

Attachment:- Assignment Files.rar

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92367061

Have any Question?


Related Questions in Computer Engineering

Systems analysis project 12 please answer the 2 questions1

Systems analysis project 12: please answer the 2 questions 1. Develop a process for managing change requests and design a form to handle a generic change request. The process should include a contingency plan for changes ...

Assume that the pizza market consists of two firms conans

Assume that the pizza market consists of two firms, Conan's and Pizza Hut. The price of a Conan pizza is denoted by Pc and the price of a Pizza Hut Pizza is P h.  Both sellers have a marginal cost of $5 for another pizza ...

Question suppose the distance between two ends of an

Question : Suppose the distance between two ends of an Ethernet LAN with a transmission rate of R bps is d meters. Can you derive a formula to find the minimum frame size, L, needed for an Ethernet packet? Using this for ...

Question need two different postsresponses with 200 words

Question: need two different posts(responses) with 200 words each on the below topic. There are three levels of management hierarchy: strategic, managerial and operational. Part 1: Review at least 4 academically reviewed ...

Question project assignment is to have you do more research

Question: Project assignment is to have you do more research on the physical security topic. In theory, everything may look straight forward, however, in real life it might not be like that. In this project you will need ...

Question synchronization barriers are a common paradigm in

Question : Synchronization barriers are a common paradigm in many parallel applications. A barrier is supposed to block a calling thread until all N threads have reached the barrier. (Parallel applications often divide u ...

A community hospital wants to estimate the body mass index

A community hospital wants to estimate the body mass index (BMI) of its local population. To estimate the BMI with an error of at most 0.5 at a 95% confidence level, what sample size should they use? The standard deviati ...

Discuss the relationship between fundamental analysis and

Discuss the relationship between fundamental analysis and intrinsic value. Include real-world examples in your explanation.

System analysis project can you answer the 4 questions at

System Analysis project: can you answer the 4 questions at the task section. Personal Trainer, Inc. owns and operates fitness centers in a dozen Midwestern cities. The centers have done well, and the company is planning ...

Use state-transition testing to solve the following testing

Use state-transition testing to solve the following testing problem. In a course registration system, students can register for a given course when the course is in the open state. At the end of the registration period, ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As