The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 1 Day Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Overview
You have just been hired by a local building contractor to design program for his company. He has been hiring a number of people to finish a job he is working on. After numerous bad cuts on woods, he realizes that some of his employees have a problem in converting feet to inches and inches to feet. He needs you to design a program that will allow his employees to do these conversions easily.
Instructions
Knowing that one foot equals 12 inches, you are to write two functions, one named feet_to_inches and the other named inches_to_feet that accept a number of feet or a number of inches as an argument and returns the appropriate number in inches or feet. For example, if the user enters 10 feet, the feet_to_inches function should return 120 inches. Or, if the user enters 60 inches, the inches_to_feet function should return 5 feet.
Use the functions in a program that prompts the user to enter the number of feet or the number of inches and then displays the number of inches in that many feet or the number of feet in that many inches.
Additional Requirements
Â
//Flor Torres
//This program is designed to help the user convert feet to inches
//and inches to feet.
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
//Function prototypes
void getInchesToFeet(double, double );
void getFeetToInches(double, double);
int main()
{
   //Introduction
   cout << "Harry's Contracting" << endl;
   cout << "-----------------------------------------" << endl;
   cout << "Feet to Inches / Inches to Feet Converter" << endl;
   cout << "-----------------------------------------" << endl << endl;
   int choice;
   //Display the menu
   cout << "Converter Options\n";
   cout << "----------------\n";
   cout << "1. Convert INCHES to feet\n";
   cout << "2. Convert FEET to inches\n";
   cout << "3. Quit\n";
   cout << "Enter your choice: ";
   cin >> choice;
   //Validate user input
   while (choice < 1 || choice > 3)
   {
      cout << "Invalid selection. Enter 1, 2, or 3: ";
      cin >> choice;
   }
   if (choice = 1)
   {
      getInchesToFeet(double inches, double totalFeet);
   }
   else if (choice = 2)
   {
      getFeetToInches(double feet, double totalInches);
   }
   else
   {
      return 0;
   }
   system("pause");
   return 0;
}
//Inches to feet conversion
void getInchesToFeet(double inches, double totalFeet)
{
   double inches;
   double totalFeet = inches / 12;
   cout << "Enter the number of inches you to convert to feet: ";
   cin >> inches;
   cout << "The total feet that you will need is: " << totalFeet << endl;
   cout << fixed << showpoint << setprecision(2);
}
//Feet to inches conversion
void getFeetToInches(double feet, double totalInches)
{
   double feet;
   double totalInches = feet * 12;
   cout << "Enter the number of FEET you want to convert to inches: ";
   cin >> feet;
   cout << "The total inches that you will need is: " << totalInches << endl;
   cout << fixed << showpoint << setprecision(2);
}
I'm having a hard time getting my functions to work. I think I'm not declaring them correctly.
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly