C How to Program (8th Edition)
C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
Question
Book Icon
Chapter 7, Problem 7.33MD
Program Plan Intro

Program Plan:

  • Declare prototype for three functions building_CF, car_CF and bicycle_CF.
  • Inside main function,
    • Declare array of function f to point to three functions building_CF, car_CF and bicycle_CF.
    • Declare an integer variable choice to store the user’s choice
    • Use while loop to repeatedly take user’s choice and call different function using array of function.
  • Define function building_CF. Inside this function ask from user for various parameters that can contribute to CO2 emission. Based on value of these paramters and emission factor calculate the carbon foot print for building.
  • Similar as above define function car_CF and bicycle_CF. The CO2 emission of car will be based on type of fuel used in it and for bicyle CO2 emission will depend on the distance travelled.

Summary Introduction: The program uses CO2 emission factors of various fuels used to calculate the carbon footprint for any building, car or bicycle. The program defines three functions for each type of carbon footprint calculation and calls them using array of function.

Program Description:The program prompts the user to enter the type of carbon footprint to calculate and then based on his/her choice uses the array of function to calculate the carbon footprint.

Blurred answer
Students have asked these similar questions
Using C++ Programming language: Assume you want a function which expects as parameters an array of doubles and the size of the array. Write the function header that accepts these parameters but is defined in such a way that the array cannot be modified in the function.  You can use your own variable names for the parameters.
CODE USING C++ 1. Please Fix Me by CodeChum Admin Hi dear Programmer, I am broken.   Can you please help me fix me? ??     Instructions: In the code editor, you are provided with a main() function that declares an array, sets its values, and then prints the sum of all of its values. However, there is a problem with how the array is declared. The array should be able to store 5 values. Your task is to fix the me array's declaration. Output 25
please answer within 30 minutes.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr