Preview

Programming Homework

Satisfactory Essays
Open Document
Open Document
823 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Programming Homework
COMP122
Week 1 Homework

Part 1: Complete the following problems.

1. A) Write a function in C++ to the following specifications:
Function name: even
Return type: bool
Parameter list: int n
Statements in the body: if (n % 1 == 0) return (true); else return (false);

B) What do you think the purpose of function? Write appropriate comments into the function to reflect this purpose.

C) Draw a corresponding flow chart that reflects the steps in the functions.

D) Write a program that includes this function. The main function should call the “even” function two times once with 232 as the argument and the second time with 137. The main function should include statements to display the return the values from the “even” function along with appropriate labels.

2. Suppose that the cost of sending an international fax is calculated as follows: Service charges $3.00; $0.20 per page for the first 10 pages; and $0.10 for each additional page. Design an algorithm that asks the user to enter the number of pages to be faxed. The algorithm then uses the number of pages to be faxed to calculate the amount.
Inputs:
Const Double serviceCharge = 3.00
Const Double perpageCostForFirst10Pages
Const double perpagecostforadditionalpages
Int numOfPages;
Outputs:double Cost of fax

Processes: Prompt for and read numOfPages, Test if numOfPages > 10

3. Bob enters a pizza shop and notices there are three different sizes of pizzas available. Sizes are given as the diameter of the pizza in inches. The cost of a pizza is based on the size. Bob would like to know which size of pizza has the lowest cost per square inch.

a. Identify the inputs and outputs for this problem.

b. Identify the processing needed to convert the inputs to the outputs.

c. Design an algorithm in pseudocode to solve this problem. Make sure to include steps to get each input and generate each output.

Part 2: Complete the

You May Also Find These Documents Helpful

  • Satisfactory Essays

    c. Func3 has four parameters. Func3 is a char function. d. Join has two parameters. Join is a string function e. 2; int and double, int first and then double f. func1(3, 8.5) g. Problem 4 double func(double& x, double& y, double& z) { if (pow(x, y) =…

    • 188 Words
    • 1 Page
    Satisfactory Essays
  • Powerful Essays

    4. The calculation should be executed only after all the valid input values are provided.…

    • 1488 Words
    • 6 Pages
    Powerful Essays
  • Good Essays

    2. Compare cost per square inch of pizza for each pan size offered by a restaurant.…

    • 1753 Words
    • 8 Pages
    Good Essays
  • Satisfactory Essays

    b. Include the function written in Exercise 2a in a working program. Make sure your function…

    • 720 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    cout << "You are in factorial program of C++. Please enter a +ve integer:- ";…

    • 426 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    It/210 Final Exam

    • 1235 Words
    • 5 Pages

    4. The calculation should be executed only after all the valid input values are provided.…

    • 1235 Words
    • 5 Pages
    Good Essays
  • Satisfactory Essays

    Homework Week 2

    • 743 Words
    • 3 Pages

    5. Bob enters a pizza shop and notices there are three different sizes of pizzas available. Sizes are given as the diameter of the pizza in inches. The cost of a pizza is based on the size. Bob would like to know which size of pizza has the lowest cost per square inch.…

    • 743 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    B. Then click on the Information button and review the information there. Close the window when done.…

    • 2517 Words
    • 11 Pages
    Powerful Essays
  • Satisfactory Essays

    unit 3

    • 313 Words
    • 2 Pages

    5. Write a pseudocode statement that declares the variable cost so it can hold real number.…

    • 313 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    UNIT 2

    • 470 Words
    • 3 Pages

    Type in your answers below where the question marks are shown based on the above problem…

    • 470 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    3. Write assignment statements that perform the following operations with the variables a, b, and c.…

    • 748 Words
    • 3 Pages
    Powerful Essays
  • Satisfactory Essays

    code program

    • 317 Words
    • 2 Pages

    (Input screenshot) - Insert here a screenshot of your program running showing entry of the provided set of test input data for this assignment:…

    • 317 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Coding in Grade School

    • 1178 Words
    • 5 Pages

    I recently watched a video that struck my interest. It was a video created and funded by a foundation named Code.org. The basic premise of this video is to show how important coding was for several founders of multi-million dollar companies such as Microsoft (Bill Gates) and Facebook (Mark Zuckerberg), and how coding is not taught in grade school. Because coding is a specialized skill and requires specific instruction, it is not a course that would be offered to kids in grade school. The reason the CEOs of these companies made it big were because they had access to computers and resources and their craft was unique; something kids of the 70’s and 80’s lacked. In the present world where most information can be found with the click of a button, it makes it easier for kids of the newer generations to learn coding. Who knows what kind of innovations the future kids of the world hold as potential in their hands and mind? With that being said, it is essential, that in the near future, public and private schools implement coding in their curriculum in order to broaden the knowledge of the future kids of this fast-moving technological era.…

    • 1178 Words
    • 5 Pages
    Good Essays
  • Good Essays

    Programming Methods

    • 578 Words
    • 3 Pages

    This assignment gave me the opportunity to computerize a manual membership system of Richard’s Tennis Club using various methods and techniques. The computerization of this system introduced several advantages but also created some limitations.…

    • 578 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Prorgraming

    • 846 Words
    • 4 Pages

    The objective and scope of my Project Online Quiz System is to record the details various activities of user. It will simplify the task and reduce the paper work. During implementation every user will be given appropriate training to suit their specific needs. Specific support will also be provided at key points within the academic calendar. Training will be provided on a timely basis, and you will be trained as the new is Online Quiz System rolled out to your area of responsibility.…

    • 846 Words
    • 4 Pages
    Good Essays