自己写的 欢迎探讨纠错呀
#include <iostream>
using namespace std;
void question_1();
void question_2();
void question_3();
void question_4();
void question_5();
void question_6();
void question_7();
int main()
{
question_7();
return 0;
}
void question_1()
{
int height;
const int inch2foot = 12;
cout << "Enter your height(inch) : ___\b\b\b";
cin >> height;
cout << endl;
cout << "Your height is " << height/inch2foot << "\'" << height % inch2foot << "\""<< endl;
return;
}
void question_2()
{
int height_in , height_ft , height;
double height_m , weight_pd , weight_kg;
const int inch2foot = 12;
const double foot2meter = 0.0254;
const double kg2pound = 2.2;
cout << "Enter your height(inch) : ___\b\b\b";
cin >> height_in;
cout << "height(foot) : __\b\b";
cin >> height_ft;
cout << endl;
cout << "Enter your weight(pound) : ___\b\b\b";
cin >> weight_pd;
cout << endl;
height = inch2foot * height_in + height_ft;
height_m = inch2foot * height;
cout << "Your height is " << height << " foot, which means " << height_m << " meters." << endl;
weight_kg = weight_pd / kg2pound;
cout << "Your BMI is " << weight_kg/(height_m * height_m) << endl;
return;
}
void question_3()
{
int degrees , minutes , seconds;
const double convert = 60.0;
cout << "Enter a latitude in degrees , minutes and seconds: " << endl;
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;
cout << degrees << " degrees, " << minutes << " minutes, " << seconds << " seconds = ";
cout << degrees + minutes / convert + seconds / convert / convert << " degrees." << endl;
return;
}
void question_4()
{
long long int time , time_left;
long int days;
int hours, minutes , seconds;
cout << "Enter the number of seconds: ";
cin >> time;
days = time / (60 * 60 * 24);
time_left = time - 60 * 60 * 24 * days;
hours = time_left / (60 * 60);
time_left -= 60 * 60 * hours;
minutes = time_left / 60;
seconds = time_left - 60 * minutes;
cout << time << "seconds = " << days << " days, " << hours << " hours, " << minutes << " minutes, " << seconds << " seconds." << endl;
return;
}
void question_5()
{
long long int pop_world , pop_us;
cout << "Enter the world's population: ";
cin >> pop_world;
cout << "Enter the population of the US: ";
cin >> pop_us;
cout << "The population of the US is " << ((long double) pop_us / pop_world) * 100.0 << "% of the world population." << endl;
return;
}
void question_6()
{
double length , oil;
cout << "Enter the district: ";
cin >> length;
cout << "Enter the oil used: ";
cin >> oil;
cout << "Your car uses oil " << oil / (length / 100.0) << "/100km." << endl;
return;
}
void question_7()
{
double oil;
cout << "Enter the oil assumption of your car in European way(L/100km): ";
cin >> oil;
cout << "The oil assumption of your car in America way is " << 62.14 / (oil / 3.875) << "mpg" << endl;
return;
}