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

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 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