美文网首页
C++ primer plus 第三章 编程练习 第二题 程序样

C++ primer plus 第三章 编程练习 第二题 程序样

作者: 今天恐怕幼稚不完 | 来源:发表于2018-08-06 17:39 被阅读0次

在学习C++的过程中做的练习。已经跑通。

#include <iostream>

int main()

{

using namespace std;

double feet, inch, pound;

const double change1 = 0.0254;

const double change2 = 2.2;

cout << "Enter your feet : ";

cin >> feet;

cout << "Enter your inch : ";

cin >> inch;

double shengao = (feet * 12 + inch) * change1;

cout << "Your height is : " << shengao  << " meters. " << endl;

cout << "Enter your weight : ";

cin >> pound;

double zhongliang = pound / change2;

cout << "Your weight is "<< zhongliang  << " kilograms. "<< endl;

cout << "Your BMI is: " <<  zhongliang / ( shengao * shengao ) << ' . ' << endl;

cin.get();

cin.get();

return 0;

}

相关文章

网友评论

      本文标题:C++ primer plus 第三章 编程练习 第二题 程序样

      本文链接:https://www.haomeiwen.com/subject/gfvgvftx.html