I cant do my home work,please help me.i am stuck

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tukriss
    New Member
    • Nov 2006
    • 2

    I cant do my home work,please help me.i am stuck

    please give me the answer to this question
    The distance between two cities in killometers is input through a keyboard.
    Write a C program to convert and print this distance in;
    1.Meters
    2.Feets
    3.Inchs
    4.Centimeters
    thank you.
  • DeMan
    Top Contributor
    • Nov 2006
    • 1799

    #2
    Hopefully you know how to write code.....

    1)there are 1000 metres in a kilometre
    2) a foot is (approximately) 30 centimetres
    3) an inch is (approximately 2.54 centremetres, alternatively 12 inches are [approximately] 1 foot)
    4) There are 100 Centimetres in a metre.

    Using the information above you can consruct a method to convert km into any of the units mentioned here.

    If you want help with the actual code I suggest you submit some of your own. There are many people here more than willing to help with your assignment, but few who would do your assignment for you.

    Comment

    • thefarmer
      New Member
      • Nov 2006
      • 55

      #3
      Originally posted by tukriss
      please give me the answer to this question
      The distance between two cities in killometers is input through a keyboard.
      Write a C program to convert and print this distance in;
      1.Meters
      2.Feets
      3.Inchs
      4.Centimeters
      thank you.
      hi there,

      actually i can code to you by now but i do'nt have such enough time to spent with you , ive post some introduction then i let tou to finish it by your self ok!!!

      #include <iostream.h>
      #include <conio.h>
      #include <math.h>

      double GetInput();
      double convertToMeters ( double);
      double convertToFeets ( double);
      double convertToInches (double);
      double convertToCentim eters (double);

      int main ();

      {

      cout << " Welcome To Unit Conversion:\n ";
      cout <<" 1. Convert Unit to Meters:\n";
      cout <<" 2. // put all the other stuff you needed
      ............... ............... .........
      cout << "4. " Exit";

      {

      double input;
      double converted;
      int choice = -1;

      while (choice !=4)

      {
      cin>> choice;
      if (choice !=4)

      {

      input = GetInput ();

      if ( choice == 1)
      converted = convertToMeters ( input);
      else if ( choice == 2)
      converted = convertToFeets ( input);

      //........input others similar to this up to

      else if (choice >=5) // for wrong input selection
      cout <<" wrong input:";
      cout<<" you convert:\t" << input << converted;
      }
      }
      }

      getch ();
      return 0;
      }

      double GetInput()
      {

      cout <<" enter Unit:\t";
      double input;
      cin >> input;
      return input;
      }
      double convertToMeters ( double input)
      {
      return input * ( // put the formula to convert it to meters // do not put "=" sign on it ,put semi-colon after the fomula ok!!!!)
      }
      double convertToFeets ( double input)
      {
      //similar to above but to feet
      }
      //do the same in the remaing two

      double convertToInches (double)
      double convertToCentim eters (double)

      }

      then compile it, note that this is case sensitive ok be sure not to miss something

      regards,
      mike

      Comment

      Working...