//-------------------------------------------------------------------- // // Example showing I/O stream basics basics.cpp // //-------------------------------------------------------------------- // Converts the weight of a precious stone from carats to ounces. // A carat is equal to 200 milligrams -- the approximate weight of // one carob seed. #include // Declarations for the cin and cout streams void main () { double caratWt, // Weight of stone in carats ounceWt; // Weight of stone in ounces // Output the prompt string. Note that the cursor remains on the // same line after the string is output. cout << "Enter weight (in carats): "; // Read in the stone's weight. cin >> caratWt; // Compute the equivalent weight in ounces. ounceWt = caratWt * 0.2 / 28.35; // Output the result. cout << "This stone weighs " // Output a string << ounceWt // Output a numeric value << " ounces." // Output another string << endl; // Move the cursor to the next line // Output a blank line. cout << endl; // Output the result again (just for the heck of it). cout << "This stone weighs " << ounceWt << " ounces." << endl; // Output another blank line followed by "THE END". cout << endl << "THE END" << endl; }