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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
|
#include <iostream>
using namespace std;
// Function Prototypes
float currency(float rcur, float ecur, float & exc);
float mm(float inches, float & ina);
float in(float mms, float & mma);
float addm(float adder, float & ans);
float sub(float num1, float num2, float & ans);
float mul(float num1, float num2, float & ans);
float div(float num1, float num2, float & ans);
char namec(char namechk, char & names);
int main()
{
int selection, twoselection;
float rcur;
float ecur;
float exc;
cout <<"This is the program to do the following. Select as desired: "<<endl;
cout <<"1: Currency"<<endl;
cout <<"2: Inches to MM"<<endl;
cout <<"3: ADD"<<endl;
cout <<"4: Subtract"<<endl;
cout <<"5: Multiply"<<endl;
cout <<"6: Divide"<<endl;
cout <<"7: Name Check"<<endl;
cin >> selection;
switch (selection)
{
case 1:
cout <<"This is the option to convert currency: "<<endl;
cout <<"Enter actual currency: ";
cin >> rcur;
cin.ignore();
cout <<"\n"<<endl;
cout <<"Enter exchange rate: ";
cin >>ecur;
cin.ignore();
currency(rcur, ecur, exc);
cout <<"The exchange value for "<<rcur<<" is"<< exc<<endl;
break;
case 2:
cout <<"This is the program to convert inches to mm: "<<endl;
cout <<"What would you like to do ?" <<endl;
cout <<"1: INCHES to MM"<<endl;
cout <<"2: MM to INCHES"<<endl;
cin >> twoselection;
switch(twoselection)
{
float inches, mms;
float ina, mma;
case 1:
cout <<":Welcome to INCHES to MM conversion:"<<endl;
cout <<"Enter inches to convert: ";
cin >> inches;
mm(inches, ina);
cout <<"The conversion of "<<inches<<" is"<<ina <<endl;
break;
case 2:
cout <<"Welcome to MM to INCHES conversion"<<endl;
cout <<"Enter MM to convert: "<<endl;
cin >> mms;
in(mms, mma);
cout <<"The conversion of "<<mms << " is "<< mma<<endl;
break;
default:
break;
}
case 3:
int numbers;
int count;
float adder;
float ans, anss, total;
total = 0;
anss = 0;
cout <<"This adds the value of given numbers: "<<endl;
cout <<"Enter how many numbers to add? "<<endl;
cin >> numbers;
for (count = 1; count <= numbers; count++)
{
cout <<"Enter "<<count<<" value: ";
cin >> adder;
total = addm(adder, anss);
}
cout <<"The sum is "<< total <<endl;
break;
case 7:
char namechk[10];
char names;
char rnames;
cout <<"This program check if the name is in the database: "<<endl;
cout <<"Enter the desired name: "<<endl;
cin.get(namechk, 10, '\n');
cin.ignore(10, '\n');
namec(namechk, rnames);
cout <<"The names "<<"""<<namechk<<"""<<" & "<<"""<<namechks<<"""<<" are "<< rnames <<endl;
break;
default:
break;
}
}
float currency(float rcur, float ecur, float & excs)
{
excs = rcur * ecur;
return excs;
}
float mm (float inches, float & inas)
{
inas = 25.4 * inches;
return inas;
}
float in (float mms, float & mmas)
{
mmas = 0.04 * mms;
return mms;
}
float addm(float adder, float &anss)
{
anss = anss + adder;
return anss ;
}
char namec(char namechk, char & rnames)
{
int result;
char namechks[10];
cout <<"Enter another name to check with "<<"""<<namechk<<""\n\n"<<endl;
cin.get(namechks, 10, '\n');
cin.ignore(10,'\n');
result = strcmp(namechk, namechks);
switch (result)
{
case 1:
cout <<"Its correct"<<endl;
break;
case 2:
cout <<"Its not correct"<<endl;
break;
}
return rnames;
}
|