Apple

  • Uploaded by: Saravanan Raj
  • 0
  • 0
  • August 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Apple as PDF for free.

More details

  • Words: 337
  • Pages: 2
#include #include // defined constant for price per apple #define PRICE_PER_APPLE 0.85 // defined constant for price per orange #define PRICE_PER_ORANGE 1.00 using namespace std;

// function prototypes void display_heading(void); void display_apple_item(int qty, double total); void display_orange_item(int qty, double total); void display_grand_total(double grand_total); int main(void) { int apple_qty, orange_qty; double apple_total, orange_total, grand_total; // get number of apples and oranges cout << "Enter number of apples: "; cin >> apple_qty; cout << "Enter number of oranges: "; cin >> orange_qty; // compute total for apples and oranges apple_total = apple_qty * PRICE_PER_APPLE; orange_total = orange_qty * PRICE_PER_ORANGE; // compute grand total grand_total = apple_total + orange_total; // write the function calls to display the result

return 0; } void display_heading(void) { cout << "=========My Fruit Store========\n"; cout << "Fruit Qty Price Total\n"; cout << "-------------------------------\n"; } void display_apple_item(int qty, double total) { cout << "Apple\t" << setw(3) << qty; cout << " RM" << setw(4) << fixed << setprecision(2) << PRICE_PER_APPLE; cout << "\tRM" << setw(5) << fixed << setprecision(2) << total << endl; } void display_orange_item(int qty, double total) { cout << "Orange\t" << setw(3) << qty; cout << " RM" << setw(4) << fixed << setprecision(2) << PRICE_PER_ORANGE; cout << "\tRM" << setw(5) << fixed << setprecision(2) << total << endl; }

void display_grand_total(double total) { cout << "-------------------------------\n"; cout << "Total\t\t\tRM" << setw(5) << fixed << setprecision(2) << total << endl; }

#include #include using namespace std; void get_data(double& velocity, double& time, double& accel); double get_distance(double velocity, double time, double accel); int main(void) { double init_velocity, time, acceleration, distance; get_data(init_velocity, time, acceleration); distance = get_distance(init_velocity, time, acceleration); cout << "Distance is " << distance << endl; return 0; } void get_data(double& velocity, double& time, double& accel) { cout << "Enter initial velocity: "; cin >> velocity; cout << "Enter time: "; cin >> time; cout << "Enter acceleration: "; cin >> accel; } double get_distance(double velocity, double time, double accel) { return(velocity * time + 0.5 * accel * pow(time, 2.0)); }

Related Documents

Apple
May 2020 33
Apple
August 2019 53
Apple
April 2020 28
Apple
April 2020 29
Apple Company.docx
November 2019 17
Apple Seeds
October 2019 37

More Documents from "Rev Andrew Salinas"

Pseudo Code
August 2019 43
P13 E1 Saravanan Raj
August 2019 40
Apple
August 2019 53
Maya08 Broch Overview V17 1
December 2019 43
Minggu 1
August 2019 39
Kehadiran Mesyuarat Pj
August 2019 60