#include <iostream>
void feetAndInchesToMetersAndCent(int feet, double inches, int &meters, double ¢) {
inches = 12 * feet + inches;
cent = inches * 2.54;
meters = cent / 100;
cent -= meters * 100;
}
void metersAndCentTofeetAndInches(int meters, double cent, int &feet, double &inches) {
cent = 100 * meters + cent;
inches = cent / 2.54;
feet = inches / 12;
inches -= feet * 12;
}
void showChoices() {
std::cout << "-------------------------------------------------\n";
std::cout << "Choose convertation:\n";
std::cout << "1) from feet and inches to meters and centimeters\n";
std::cout << "2) from meters and centimeters to feet and inches\n";
std::cout << "3) exit\n";
std::cout << "> ";
int choice;
int feet, meters;
double inches, cent;
std::cin >> choice;
if (choice == 1) {
std::cout << "Enter feet: ";
std::cin >> feet;
std::cout << "Enter inches: ";
std::cin >> inches;
feetAndInchesToMetersAndCent(feet, inches, meters, cent);
std::cout << "Meters: " << meters << "\n";
std::cout << "Centimeters: " << cent << "\n\n";
}
else if (choice == 2) {
std::cout << "Enter meters: ";
std::cin >> meters;
std::cout << "Enter centimeters: ";
std::cin >> cent;
metersAndCentTofeetAndInches(meters, cent, feet, inches);
std::cout << "Feet: " << feet << "\n";
std::cout << "Inches: " << inches << "\n\n";
}
else if (choice == 3) {
exit(0);
}
}
int main()
{
while (true) {
showChoices();
}
}
Comments
Leave a comment