-
Notifications
You must be signed in to change notification settings - Fork 0
/
modUnit.h
122 lines (104 loc) · 2.11 KB
/
modUnit.h
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//Unit Converter Module
//
//Header File for Unit Converter Module
//
//Done by A.Alkaff Ahamed (Alkaff Paiya)
//
//Copyright 2016
#include<iostream>
#include<cmath>
#include<cstring>
#include"modLogger.h"
#ifndef MODUNIT_H
#define MODUNIT_H
using namespace std;
//Inheritance is done to this class only
class length: public logger
{
private:
float m, cm, in, ft, yd, x;
logger L;
int display(int n)
{
cout<<cm<<" cm"<<endl;
cout<<m<<" m"<<endl;
cout<<in<<" inches"<<endl;
cout<<ft<<" foot"<<endl;
cout<<yd<<" yards"<<endl;
logFile(n);
}
int logFile(int u)
{
//int u is passed all the way from the Main Function int sel
//for the case of invalid operations
if (u == 0 || u > 5)
{
L.logUnitInput(0, 0);
L.logUnitResult(cm, m, in, ft, yd, 0);
}
else
{
L.logUnitInput(x, u);
L.logUnitResult(cm, m, in, ft, yd, u);
}
}
public:
int getData(int n)
{
x = n;
}
int invalid (int a)
{
logFile(a);
}
float centimeter(int j)
{
cm = x;
m = cm/100;
in = cm/2.54;
ft = in/12;
yd = ft/3;
cout<<x<<" cm is:\n";
display(j);
}
float meter(int j)
{
m = x;
cm = m*100;
in = cm/2.54;
ft = in/12;
yd = ft/3;
cout<<x<<" m is:\n";
display(j);
}
float inch(int j)
{
in = x;
cm = 2.54*in;
m = cm/100;
ft = in/12;
cout<<x<<" inch is:\n";
display(j);
}
float feet(int j)
{
ft = x;
in = 12*ft;
cm = 2.54*in;
m = cm/100;
yd = ft/3;
cout<<x<<" feet is:\n";
display(j);
}
float yard(int j)
{
yd = x;
ft = yd*3;
in = 12*ft;
cm = 2.54*in;
m = cm/100;
cout<<x<<" yard is:\n";
display(j);
}
};
#endif