Can someone kindly take a look and tell me what I am doing wrong?
#include <iostream>
//This program prompts the user to enter
// Feet and Inches and calculates the Cenimeters
// It also checks to make sure the user doesnt
// enter a negative number
using namespace std;
double inches; // number of inches
double foot; //number of feet
double centimeters; // number of centimeters
double totalinch; //used to calculate total inches
double totalfoot; //used to calcuate total centimeters in foot
int response; // users menu response
int main()
{
do
{
cout << " Feet and inches into Centimeters" << endl;
cout << endl;
cout << "1 - Run Program" << endl;
cout << "0 - End Program" << endl;
cout << endl;
cout << "Enter Selection : ";
// get users response
cin >> response;
if (response == 1)
{
// process inches to centimeters
cout << "Enter length in feet: "<<endl;
cin >> foot;
cout<<"Enter inches as well:"<<endl;
cin>>inches;
cout<<endl;
try
{
totalinch = inches * 2.54;
totalfoot = foot * 30.48;
centimeters = totalfoot+totalinch;
if(foot<=0)
throw -1;
}
catch (int error)
{
}
cout << "Centimeters in "<<foot<<" foot is "<<totalfoot<<endl;
cout <<"Centimeters in " <<inches<<" inches is "<<totalinch<<endl;
cout <<"Total Centimeters is "<<centimeters<<endl;
cout <<endl;
}
}while (response !=0);
return 0;
}

New Topic/Question
Reply



MultiQuote


|