Thread: Help with C++! Feet and inches to meters and centimeters and vice versa program

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    6

    Help with C++! Feet and inches to meters and centimeters and vice versa program

    So I've set up the if else and loop for the program. I've hit a brick wall with the conversions. Let's say i enter 5 feet and 4 inches. I need it to say 1 meters and 62.56 centimeters and vice versa when i do the other option. How do I do coding for the necessary calculations for the output?? Please help.. I am a beginner and just started taking a course at school.

    Code:
    #include<iostream>
    using namespace std;
    void main()
    {
    	int choice;
    	do
    	{
    	float ft,in,m,cm;
    	
    	cout<<"Choose Task:"<<endl;
    	cout<<"1.Convert Feet and Inches to Meters and Centimeters."<<endl;
    	cout<<"2.Convert Meters and Centimeters to Feet and Inches."<<endl;
    	cout<<"Enter 0 to end program."<<endl;
    	cin>>choice;
    	if (choice==1)
    		{
    		cout<<"Enter Feet: ";
    		cin>>ft;
    		cout<<"Enter Inches: ";
    		cin>>in;
    		cout<<"The total feet and inches in meters and centimeters is "<<()<<"m and "<<()<<"cm."<<endl;
    		cout<<" "<<endl;
    		}	
    	else if (choice==2)
    		{
    		cout<<"Enter Meters: ";
    		cin>>m;
    		cout<<"Enter Centimeters: ";
    		cin>>cm;
    		cout<<"The total meters and centimeters in feet and inches is "<<()<<" ft and "<<()<<" in."<<endl;
    		cout<<" "<<endl;
    		}
    	}
    	while(choice!=0);
    
    	if(choice==0)
    		cout<<"Program Ended."<<endl;
    }
    Last edited by ricefangiez; 07-05-2010 at 06:29 PM.

Popular pages Recent additions subscribe to a feed