首页 > 代码库 > Conversion of feet/inches to meters-英尺、英里装换为米
Conversion of feet/inches to meters-英尺、英里装换为米
Conversion of feet/inches to meters-英尺、英里装换为米,允许重复计算:
//Conversion of feet/inches to meters-英尺、英里装换为米,允许重复计算 #include<iostream> #include<cmath> using namespace std; void get_input(double& feet,double& inch); double convert(double& feet,double& inch,double& meter); void output(double meter); int main() { double feet,inch,meter; char ans; do{ get_input(feet,inch); convert(feet,inch,meter); output(meter); cout<<"Do you want again?"; cin>>ans; }while(‘y‘ == ans || ‘Y‘ == ans); return 0; } void get_input(double& feet,double& inch) { cout<<"Enter the feet and the inch:\n"; cin>>feet>>inch; } double convert(double& feet,double& inch,double& meter) { double tem; tem = feet + inch / 12; meter = tem * 0.3048; } void output(double meter) { cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); cout<<"The result is "<<meter<<"m"<<endl; }
结果:
Enter the feet and the inch: 5 7 The result is 1.70m Do you want again?y Enter the feet and the inch: 245 0 The result is 74.68m Do you want again?
Conversion of feet/inches to meters-英尺、英里装换为米
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。