1.
#include <iostream>
int main()
{
using namespace std;
const int factor = 12;
int h,feet;
cout << "height:____\b\b\b";
cin >> h;
feet = h / factor;
h = h%factor;
cout <<endl<< "ft:" << feet << "\tin:" << h;
cin.get();
cin.get();
}
2.
#include <iostream>
int main()
{
using namespace std;
const int ftToIn = 12;
const double inToM = 0.0254;
const double kgToPn = 2.2;
int inch,feet;
double BMI,pound;
double h,w;
cout << "inch:____\b\b\b";
cin >> inch;
cout << endl << "feet:____\b\b\b";
cin >> feet;
cout << endl << "Pound:____\b\b\b";
cin >> pound;
inch = feet * 12 + inch;
h = inch*inToM;
w = pound / kgToPn;
BMI = w / (int(h) ^ 2);
cout << endl << "BMI:" << BMI << "\th:" << h << "m\tw:" << w<<"kg";
cin.get();
cin.get();
}
3.
#include <iostream>
int main()
{
using namespace std;
const int degToMin = 60;
const int MinToSec = 60;
double deg,min,sec,d;
cout << "Enter a latitude in degrees,minutes, and seconds" << endl << "First, enter the degrees: ";
cin >> deg;
cout << "Next, enter the minutes of arc: ";
cin >> min;
cout << "Finally, enter the seconds of arc: ";
cin >> sec;
d = deg+min/degToMin+sec/MinToSec/degToMin;
cout << deg << " degrees, " << min << " minutes, " << sec << " seconds = " << d << " degrees";
cin.get();
cin.get();
return 0;
}
4.
#include <iostream>
int main()
{
using namespace std;
const int dayToH = 24;
const int hToM = 60;
const int mToS = 60;
int day,h,m,sec;
long s;
cout << "Enter the number of seconds: " ;
cin >> s;
day = s / mToS / hToM / dayToH;
h = s / mToS / hToM%dayToH;
m = s / mToS%hToM;
sec = s%mToS;
cout << s << " seconds = " << day << " days, " << h << " hours, " << m << " minutes, " << sec << " seconds";
cin.get();
cin.get();
return 0;
}
5.
#include <iostream>
int main()
{
using namespace std;
long long worP,usP;
double rat;
cout << "Enter the world's population: " ;
cin >> worP;
cout << "Enter the population of the US: ";
cin >> usP;
rat = double(usP) /double(worP)*100;
cout << "The population of the US is " << rat << "% of the world population.";
cin.get();
cin.get();
return 0;
}