3.7-1

#include<iostream>
const int change=12;
using namespace std;
int main()
{
cout<<"Please entre your height:__\b\b";//单位英寸
int height;
cin>>height;
cout<<"Your are "<<height/change<<" foot and "<<height%change<<" inch high.";
system("pause");
return 0;
}

 

3.7-2

#include<iostream>
using namespace std;
const int change1=12;
const double change2=0.0254;
const float change3=2.2;
int main()
{
int inch,foot,pound;
cout<<"请以几英尺几英寸的方式输入您的身高:";//以几英尺几英寸的方式输入
cin>>inch>>foot>>pound;
cout<<"你输入的身高为"<<inch<<"英尺6 8 "<<endl;
cout<<"你输入的身高为"<<foot<<"英寸"<<endl;
double meter,kilometer,BMI;
meter=inch*change1*change2;
kilometer=pound/change3;
cout<<"你的身高为"<<meter<<"米,体重为"<<kilometer<<"千克,";
cout<<"BMI为"<<kilometer/meter/meter<<endl;
system("pause");
return 0;
}

 

3.7-3

#include<iostream>
using namespace std;
const int change=60;
int main()
{
double degrees,minutes,seconds,result;
cout<<"Enter a latitude in degrees,minutes,and seconds:\n";
cout<<"First,enter the degrees:";
cin>>degrees;
cout<<"Next,enter the minutes of arc:";
cin>>minutes;
cout<<"Finally,enter the seconds of arc:";
cin>>seconds;
result=(seconds/change+minutes)/change+degrees;
cout<<degrees<<"degress,"<<minutes<<" minutes,"<<seconds<<" seconds = "<<result<<" degrers\n";
system("pause");
return 0;
}

 

3.7-4

#include<iostream>
using namespace std;
const int change1=60;
const int change2=24;
int main()
{
long secondTotal,minuteTotal,second,minute,hour,day;
cout<<"Enter the number of seconds:";
cin>>secondTotal;
minuteTotal=secondTotal/change1;
second=secondTotal%change1;
minute=minuteTotal%change1;
hour=minuteTotal/change1%change2;
day=minuteTotal/change1/change2;
cout<<second<<" seconds = "<<day<<" day,"<<hour<<" hours,"<<minute<<" minutes,"<<second<<" seconds\n";
system("pause");
return 0;
}

 

3.7-5

#include<iostream>
using namespace std;
int main()
{
long long population,USpopulation;
double percent;
cout<<"Enter the world's population:";
cin>>population;
cout<<"Enter the population of the US:";
cin>>USpopulation;
percent=USpopulation*1.0/population;//需要乘以1.0转成浮点数
cout<<"The population of the US is "<<percent*100<<"%"<<" of the world population.";
system("pause");
return 0;
}

 

3.7-6

#include<iostream>
using namespace std;
int main()
{
double mile,gallon,km,liter;
cout<<"请输入驱车里程(英里):";
cin>>mile;
cout<<"请输入耗油量(加仑):";
cin>>gallon;
km=mile*1.609344;
liter=gallon*3.875;
cout<<"汽车耗油量为一加仑的里程:"<<mile/gallon<<"英里,即每100公里的耗油量为"<<liter/km*100<<"升。"<<endl;
system("pause");
return 0;
}

 

3.7-7

#include<iostream>
using namespace std;
int main()
{
double US,Europe;
cout<<"请输入汽车的耗油量(每100公里消耗的汽油量(升)):";
cin>>Europe;
US=62.14/(Europe/3.785);
cout<<"汽车的耗油量为:每加仑"<<US<<"英里"<<endl;
system("pause");
return 0;
}

 

 posted on 2021-03-07 16:12  HuJiao粉  阅读(51)  评论(0)    收藏  举报