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

    Samuel Aggor CSC 1100 3/3/16 Assignment 5 Problem 1 a. Output: 3.94 b. Output: 6.67 c. Output: 15.00 d. Output: -35.00 e. Output: 0 Problem 2 a. Output: 62 b. Output: 20160 c. Output: 20 213837312 d. Output: 1 Problem 3 a. Func1 has two parameters. Func1 is an integer function. b. Func2 has three parameters. Func2 is a double function.…

    • 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
  • Powerful Essays

    c. Click on the computer monitor to view your results and transcribe them to Table 1 below.…

    • 2517 Words
    • 11 Pages
    Powerful Essays
  • Satisfactory Essays

    Comp 122 Week 1 Ilab

    • 662 Words
    • 3 Pages

    4. Identify two test cases, one using whole number values, and one using decimal number values. For each of the two test cases show what inputs you will use and what your expected outputs should be.…

    • 662 Words
    • 3 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

    Programming Logic

    • 1499 Words
    • 6 Pages

    2. Design the logic for a program that outputs every number from 1 through 10.…

    • 1499 Words
    • 6 Pages
    Good 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