//3.7.1 1英尺=12英寸
# include <iostream>
using namespace std;
int main()
{
const int change= 12;
int ft;
int inch;
cout << "Please enter your height in ft: ";
cin>> ft;
inch=change*ft;
cout <<"Your height in ft is :"<<ft<<" ft"<<endl;
cout <<"Your height in inch is :"<<inch<<" inch"<<endl;
return 0;
}
//3.7.2
# include <iostream>
using namespace std;
int main()
{
int ft,inch;
int pounds;
cout << "Please enter your height: ";
cin>>ft;
cin>>inch;
cout <<"Please enter your weight in pounds: ";
cin>>pounds;
cout<<"Your height is "<<ft<<" ft"<<inch<<" inch"<<endl;
cout <<"Your weight is "<<pounds<<" pounds"<<endl;
float mi=(ft*12+inch)*0.0254;
float kg=pounds*0.46;
float BMI= kg/(mi*mi);
cout << "Your BMI is :"<< BMI <<" BMI"<<endl;
return 0;
}
//3.7.3
# include <iostream>
using namespace std;
int main()
{
double f1=0.0166;
double f2=2.7778e-4;
int degrees,minutes,second;
double total;
cout << "Enter a latitude in degrees,minutes,and second:"<<endl;
cout <<"Firts ,enter the degrees:";
cin>>degrees;
cout <<"Next,enter the minutes of arc:";
cin>>minutes;
cout<<"Finally,enter the seconds of arc:";
cin>>second;
total=degrees+minutes*f1+second*f2;
cout <<degrees <<" degrees ,"<<minutes <<" minutes,"<<second<<" seconds="<<total<<" degrees."<<endl;
return 0;
}
//3.7.4
# include <iostream>
using namespace std;
int main()
{
const int day=86400,hour=3600,minute=60;
long int seconds;
cout <<"Enter the number of seconds: ";
cin>>seconds;
int days=seconds/day;
int hours=seconds/hour;
int minutes = seconds/minute;
cout<<seconds<<" seconeds = "<<days<<" days,"<<hours<<" hours,"<<minutes<<" minutes."<<endl;
return 0;
}