-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomeworkOne.cpp
59 lines (42 loc) · 1.58 KB
/
homeworkOne.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// CSCI40 HOMEWORK ONE
// 1/16/2016
// Thomas Asadurian
#include<iostream>
using namespace std;
int main()
{
//calculate the volume of a cylinder.
//Formula: volume of a cylinder = radius * radius * 3.14159 * height
double cylinderRadius, cylinderHeight;
const double PI = 3.14159;
cout << "This will calulate the area of a cylinder" << endl;
cout << "Input you cylinder radius: " << endl;
cin >> cylinderRadius;
cout << "Input the cylinder height: " << endl;
cin >> cylinderHeight;
cout << cylinderRadius * cylinderRadius * PI * cylinderHeight << endl;
//calculate the area of a triangle.
//Formula: 0.5 * base * height
double triangleBase, triangleHeight;
cout << "This will calculate the area of a triangle" << endl;
cout << "Input your triangle base: " << endl;
cin >> triangleBase;
cout << "Input your triangle height: " << endl;
cin >> triangleHeight;
cout << 0.5 * triangleBase * triangleHeight << endl;
//convert the temperature from Celsius to Fahrenheit.
//Formula F = (9/5)C + 32
double celcius;
cout << "This will convert celcius to fahrenheit" << endl;
cout << "Input the temperature in celcius: " << endl;
cin >> celcius;
cout << (9.0 / 5.0) * celcius + 32 << endl;
//calculate the cost according to the number of items manufactured x
//Formula C = 215,000 + 15x + 8x^2
double x;
cout << "This will calculate the cost according to the number of item manufactured" << endl;
cout << "Input the number of items: " << endl;
cin >> x;
cout << 215000 + (15 * x) * (8 * x * x) << endl;
return 0;
}