This shows you the differences between two versions of the page.

cs-142:house-functions [2014/10/14 09:08] kseppi created |
cs-142:house-functions [2014/10/14 11:07] (current) kseppi |
||
---|---|---|---|

Line 28: | Line 28: | ||

double volume_of_house(double base, double height, double depth) { | double volume_of_house(double base, double height, double depth) { | ||

- | double area, roof_height; | + | return area_of_house(base, height)*depth; |

- | | + | |

- | roof_height = base * 0.5; | + | |

- | area = area_of_house(base, height); | + | |

- | return area*depth; | + | |

} | } | ||

void add_house(double &total, double base, double height, double depth) { | void add_house(double &total, double base, double height, double depth) { | ||

- | double area, roof_height; | + | total += volume_of_house(base, height,depth); |

- | | + | |

- | roof_height = base * 0.5; | + | |

- | area = area_of_house(base, height); | + | |

- | total += area*depth; | + | |

} | } | ||

Line 56: | Line 48: | ||

cout << "R compute the area of a rectangle\n"; | cout << "R compute the area of a rectangle\n"; | ||

cout << "H compute the area of a house\n"; | cout << "H compute the area of a house\n"; | ||

- | cout << "V compute the volumne of a house\n"; | + | cout << "V compute the volume of a house\n"; |

- | cout << "A compute the volumne of a house, and add it to the neighborhood\n"; | + | cout << "A compute the volume of a house, and add it to the neighborhood\n"; |

cout << endl; | cout << endl; | ||

cout << "S to stop\n"; | cout << "S to stop\n"; |