I have some difficulty with this code.

Write a program that prompts user to enter a length in feet and inches and outputs the equivalent length in centimeters. If a user enter a negative number or a non digit number, throw and handle an appropriate exception and prompt the user to prompt the user to enter another set of number.

file:///media/D016-A831/unit%205%20pg%20922%20ex1.zip
#include <cstdlib>

#include <iostream>



using namespace std;



int main(int argc, char *argv[])

{

int feet, inches;

{

int number;

bool done = false;



string str = "The input stream is in the fail state.";



do

{

try

{

cout << "Enter an measurement: ";

cin >> feet;

cout << endl;



if (!cin)

throw str;



done = true;

cout << "Number = " << number

<< endl;

}

catch (string messageStr)

{

cout << " " << messageStr

<< endl;

cout << "Restoring the "

<< "input stream." << endl;

cin.clear();

cin.ignore







system("PAUSE");

return EXIT_SUCCESS;

}

What difficulties are you having, exactly?
You're a bit short on closing curly brackets. And... please use [code] tags.

-Albatross
Topic archived. No new replies allowed.