• API
• FAQ
• Tools
• Archive
SHARE
TWEET

Untitled

a guest Nov 19th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #define BOX_WEIGHT 53
2. #define BOX_LENGTH 45.0
3. #define GONDOLA_WEIGHT 65
4. #define GONDOLA_LENGTH 70.0
5. #define PASSENGER_WEIGHT 70
6. #define PASSENGER_LENGTH 80.5
7. #define LOCOMOTIVE_WEIGHT 52
8. #define LOCOMOTIVE_LENGTH 55.0
9.
10. #include <iostream>
11. #include <cmath>
12. using namespace std;
13. int main()
14. {
15.     int numOfBoxes, numOfGondolas, numOfPassengers;
16.
17.     cout << "Enter number of Box cars: ";
18.     cin >> numOfBoxes;
19.     cout << "Enter number of Gondola cars: ";
20.     cin >> numOfGondolas;
21.     cout << "Enter number of Passenger cars: ";
22.     cin >> numOfPassengers;
23.
24.     int totalCars = numOfBoxes + numOfGondolas + numOfPassengers;
25.     cout << endl << "The trains is " << totalCars << " cars long and consist of:" << endl;
26.     cout << "\t" << numOfBoxes << " box cars" << endl;
27.     cout << "\t" << numOfGondolas << " gondola cars" << endl;
28.     cout << "\t" << numOfPassengers << " passenger cars" << endl;
29.     int totalWeight = numOfBoxes * BOX_WEIGHT + numOfGondolas * GONDOLA_WEIGHT + numOfPassengers * PASSENGER_WEIGHT;
30.     double totalLength = numOfBoxes * BOX_LENGTH + numOfGondolas * GONDOLA_LENGTH + numOfPassengers * PASSENGER_LENGTH;
31.     cout << "The total weight of the cars is " << totalWeight << " tons." << endl;
32.     int numOfEngines = ceil(totalWeight / 1000.0);
33.     cout << "The number of engines required is " << numOfEngines << "." << endl;
34.     int totalWeightWithEngines = totalWeight + numOfEngines * LOCOMOTIVE_WEIGHT;
35.     double totalLengthWithEngines = totalLength + numOfEngines * LOCOMOTIVE_LENGTH;
36.     cout << "The weight of the entier train is " << totalWeightWithEngines << " tons." << endl;
37.     cout << "The total train is " << totalLengthWithEngines << " feet long." << endl;
38.
39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?