Write a program in c++ which convert the Inches into Feets

Understanding program requirements Completely mean your problem is almost solved. In this problem we first understand the mathematically conversion from one quantity to another quantity and then simply code it .

Source Code

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <Windows.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
 
 /* This Programme is basically about Conversion of Inches
 into Different types of Unit of Length */
 
 cout<<endl<<setw(60)<<"***************** Inches Conversion *******************"<<endl<<endl<<endl;
 int choice;
 // When User is complete there target then press 0 foro exist
 do
 {
  // Menu for Conversion Select according to your Requirement
  cout<<"1 : Inches to Feet"<<endl;        // Input is an Inch and output is in unit Feet
  cout<<"2 : Inches to Yard"<<endl;   // Input is an Inch and output is in unit Yard
  cout<<"3 : Inches to Meter"<<endl;   // Input is an Inch and output is in unit Meter
  cout<<"4 : Inches to CentiMeter"<<endl;  // Input is an Inch and output is in unit Centimeter
  cout<<"5 : Inches to MiliMeter"<<endl;  // Input is an Inch and output is in unit MiliMeter
  cout<<"0 : Exist"<<endl;
  cout<<endl<<setw(40)<<"Enter your Choice : ";
  double inches;
  double userInput;
  cin>>choice;                             // Here System recieve your input through cin Command
  switch(choice)
   {
     case 1:
       {
        cout<<"Enter Inches : ";
        cin>>userInput;
        inches = 0.0833 * userInput;             // Here Inches is Convert Convert into feet
        cout<<endl<<" Enter Inches : "<<userInput<<endl;
        cout<<" After Conversion feet : "<<inches<<endl<<endl<<endl;
        Sleep(5000);
       }
     break;
     
     case 2:
       {
        cout<<"Enter Inches : ";
        cin>>userInput;
        inches = 0.0277778 * userInput;     // Here Inches is Convert into Yard
        cout<<endl<<" Enter Inches : "<<userInput<<endl;
        cout<<" After Conversion Yard : "<<inches<<endl<<endl<<endl;
        Sleep(5000);
       }
     break;
     
     case 3:
       {
        cout<<"Enter Inches : ";
        cin>>userInput;
        inches = 0.0254 * userInput;     // Here Inches is Convert into Meter
        cout<<endl<<" Enter Inches : "<<userInput<<endl;
        cout<<" After Conversion Meter : "<<inches<<endl<<endl<<endl;
        Sleep(5000);
       }
     break;
     
     case 4:
       {
        cout<<"Enter Inches : ";
        cin>>userInput;
        inches = 2.54 * userInput;    // Here Inches is Convert into Centimetre
        cout<<endl<<" Enter Inches : "<<userInput<<endl;
        cout<<" After Conversion centiMeter : "<<inches<<endl<<endl<<endl;
        Sleep(5000);
       }
     break;
     
     case 5:
       {
        cout<<"Enter Inches : ";
        cin>>userInput;
        inches = 25.4 * userInput;            // Here Inches is Convert into Convert into millimetre
        cout<<endl<<" Enter Inches : "<<userInput<<endl;
        cout<<" After Conversion miliMeter : "<<inches<<endl<<endl<<endl;
        Sleep(5000);           // Waiting for Menu
       }
     break;
   }
  
 
 
 }while(choice!=0);
 
 return 0;
}


Output of the Program

Inches Convert to other Units
Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.

1 comments:

  1. Das ist eine gute Website für das Lernen. Ich mag es und apperciate. Mit einer solchen hervorragenden Arbeit.

    ReplyDelete