Example #1
0
int main(void)
{
	double x,y,z;
	std::cout<<"Enter two numbers: ";
	while(std::cin>>x>>y)
	{
		z=hmean(x,y);
		std::cout<<"Harmonic mean of "<<x<<" and "<<y
			<<" is "<<z<<std::endl;
		std::cout<<"Enter next set of numbers <q to quit>: ";
	}
	std::cout<<"Bye!\n";
	return 0;
}
int main()
{
	double x, y, z;

	std::cout << "Zadejte dve cisla: ";
	while (std::cin >> x >> y)
	{
		z = hmean(x,y);
		std::cout << "Harmonicky prumer cisel " << x << " and " << y
						<< " is " << z << std::endl;
		std::cout << "Zadejte dalsi mnozinu cisel <k pro ukonceni>: ";
	}
	std::cout << "Nashledanou!\n";
	return 0;
}
Example #3
0
File: error1.cpp Project: myler/cpp
int main(int argc, char const *argv[])
{
	double x, y, z;

	std::cout << "Enter two numbers: ";
	while(std::cin >> x >> y) {
	    z = hmean(x, y);
	    std::cout << "Harmonic mean of " << x << " and " << y
	    <<" is " << z << std::endl;
	    std::cout << "Enter next set of numbers <q to quit>: ";
	}
	std::cout << "Done." << std::endl;

	return 0;
}
Example #4
0
int main()
{
    double x, y, z;

    std::cout << "Enter two numbers: ";
    while (std::cin >> x >> y)
    {
        if (hmean(x, y, &z))
            std::cout << "Harmonic mean of " << x << " and " << y
                << " is " << z << std::endl;
        else
            std::cout << "One value should not be the negative "
                << "of the other - try again.\n";

        std::cout << "Enter next set of numbers <q to quit>: ";
    }
    std::cout << "Bye!\n";
    return 0;
}
Example #5
0
int main()
{
    double x, y, z;

    std::cout << "Enter two numbers: ";
    while (std::cin >> x >> y)
    {
        try {                   // start of try block
            z = hmean(x,y);
        }                       // end of try block
        catch (const char * s)  // start of exception handler
        {
            std::cout << s << std::endl;
            std::cout << "Enter a new pair of numbers: ";
            continue;
        }                       // end of handler
        std::cout << "Harmonic mean of " << x << " and " << y
            << " is " << z << std::endl;
        std::cout << "Enter next set of numbers <q to quit>: ";
    }
    std::cout << "Bye!\n";
    return 0;
}