Problem Statement - Computers and Programming I - Assignment, Exercises of Computer Programming

Some concept of Computers and Programming I are Practice Analyzing, Student Proctor, Practice Analyzing, Practice Array, Problem Statement. Main points of this assignment are: Problem Statement, Problem Statement, Running, Testing, Program, Expressions, Incremental Development, Practice Writing, Practice Analyzing, Nicklaus

Typology: Exercises

2012/2013

Uploaded on 04/27/2013

nazi
nazi 🇮🇳

4.5

(16)

48 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Purpose
practice analyzing a problem statement
practice editing, compiling, linking, running and testing a program
practice writing expressions
practice incremental development
Introduction
One of Nicklaus Wirth's books was entitled "Algorithms + Data Structures = Programs." In this
assignment we will work with integer and real number data types to practice converting
mathematical expressions into C++ expressions. The function we will work with is the
following:
f(x) = [(ax3-bx2)/(cx)1/2] - d
Instructions
Write a C++ program to answer the questions below. Pay attention to the coding standards for
this class!
The output of your program should be a one line answer for each of the 8 questions below. Each
answer should start with the text "question X: ", where X is replaced by the letter of the question
being answered.
DO NOT PRINT ANYTHING ELSE!!!
// question a: what is f(2) if a==13, b==5, c==6, d==7 ?
// question b: assume no change in coefficients, what is f(77)?
// question c: what is f(-2) if the coefficients are all
pf2

Partial preview of the text

Download Problem Statement - Computers and Programming I - Assignment and more Exercises Computer Programming in PDF only on Docsity!

Purpose

  • practice analyzing a problem statement
  • practice editing, compiling, linking, running and testing a program
  • practice writing expressions
  • practice incremental development

Introduction

One of Nicklaus Wirth's books was entitled "Algorithms + Data Structures = Programs." In this assignment we will work with integer and real number data types to practice converting mathematical expressions into C++ expressions. The function we will work with is the following:

f( x ) = [(a x

-b x

)/(c x )

] - d

Instructions

Write a C++ program to answer the questions below. Pay attention to the coding standards for this class! The output of your program should be a one line answer for each of the 8 questions below. Each answer should start with the text "question X: ", where X is replaced by the letter of the question being answered.

DO NOT PRINT ANYTHING ELSE!!!

// question a: what is f(2) if a==13, b==5, c==6, d==7?

// question b: assume no change in coefficients, what is f(77)?

// question c: what is f(-2) if the coefficients are all

// negative?

// question d: assuming same coefficients as question c, what is // f(-77)?

// question e: assuming same coefficients as question c, print // the larger of f(-32) and f(-8)

// question f: assume same coefficients as question c, ask the // user for an integer. // Let Z represent the integer the user typed. What is f(Z)? // BE CAREFUL! Consider all possibilities and consequences of Z!

// question g: repeat question f (ask for another integer.)

// question h: repeat question f (ask for another integer.)

Questions g and h do exactly the same thing that question f does.

TEST your code!!! I will be testing your code. You want to catch as many errors (and fix or document them) before I catch them. This is what happens in the industry. As a professional you will want to catch as many errors as you can, instead of suffering the embarrassment of having your users catch them!

How do you test your code? Think about possibilities and consequences. If the user types 5, what will my program do? Would that be valid? If my code is correct, what should the actual value of f(-77) be? Did I get that value? If not, what's wrong with my code?

Don't wait until you have written all the code to test it! Write the code to answer question a, compile and link, then test! When that's working, repeat for the next question. This is called incremental development.

Deliverables

Submit hard copy of your source code; Submit hard copy of your running results. Grading ♦ Clean compile 50%. Non-compiling code results in zero for this assignment. ♦ 50% for correctly functioning algorithms, subject to conformance to coding standards. Untested or insufficiently tested algorithms will result in proportionate deductions.