-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject1Cgradeedition.cpp
More file actions
94 lines (68 loc) · 2.76 KB
/
Project1Cgradeedition.cpp
File metadata and controls
94 lines (68 loc) · 2.76 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//CSC 160 PROJECT #1
//Purpose: C grade level program which accepts from keyboard entry miles, furlongs,
// yards, feet, and inches between two points and then displays the result
// in feet with two numbers to the right of the decimal.
//Author: Larsen J Close Most recent changes: 2/18/2016 1:40am
#include <iostream> // preprocessor directive
#include <iomanip> // needed for most manipulators
#include <cmath> // needed for sqrt()
using namespace std; // using directive
int main ( void )
{
double m; //miles
double f; //furlongs
double y; //yards
double ft; //feet
double i; //inches
double t; //total feet
cout << "This program accepts a distance in miles, furlongs, yards, feet";
cout << " and inches" << endl;
cout << "then converts those combined entries to a total number of";
cout << " feet." << endl;
cout << "Enter the number of miles: ";
cin >> m;
cout << "Enter the number of furlongs: ";
cin >> f;
cout << "Enter the number of yards: ";
cin >> y;
cout << "Enter the number of feet: ";
cin >> ft;
cout << "Enter the number of inches: ";
cin >> i;
t = ((m * 5280) + (f * 660.001) + (y * 3) + (ft) + ( i * 0.083333 ));
//5280 feet in a mile, 660.001 feet in a furlong, 3 feet in a yard\
// and 1/12 feet in an inch
cout << fixed << setprecision (2);
cout << "That distance is equivalent to " << t << " feet" << endl;
system ("pause");
return 0;
} //end main ( )
/* Display for above program
This program accepts a distance in miles, furlongs, yards, feet and inches
then converts those combined entries to a total number of feet.
Enter the number of miles: 3
Enter the number of furlongs: 2
Enter the number of yards: 172
Enter the number of feet: 2
Enter the number of inches: 9
That distance is equivalent to 17678.75 feet
Press any key to continue . . .
This program accepts a distance in miles, furlongs, yards, feet and inches
then converts those combined entries to a total number of feet.
Enter the number of miles: 8
Enter the number of furlongs: 6
Enter the number of yards: 107
Enter the number of feet: 0
Enter the number of inches: 4
That distance is equivalent to 46521.34 feet
Press any key to continue . . .
This program accepts a distance in miles, furlongs, yards, feet and inches
then converts those combined entries to a total number of feet.
Enter the number of miles: 5
Enter the number of furlongs: 0
Enter the number of yards: 201
Enter the number of feet: 1
Enter the number of inches: 11
That distance is equivalent to 27004.92 feet
Press any key to continue . . .
*/