All pastes #74538 Raw Edit

Anonymous

public text v1 · immutable
#74538 ·published 2006-06-29 04:40 UTC
rendered paste body
/*
 * Mitchell Hashimoto
 * Chapter 1 Project 1
 */

#include <iostream>
using namespace std;

int main()
{
	const double ounces_in_metric_ton = 35273.92;
	int original_ounces = 0, boxes = 0;
	double metric_tons = 0;

	cout.setf(ios::fixed);
	cout.setf(ios::showpoint);

	cout << "Enter the weight in ounces: ";
	cin >> original_ounces;

	if (original_ounces <= 0)
	{
		cerr << "Bad value entered. Should be above 0.";
		return 0;
	}

	metric_tons = original_ounces / ounces_in_metric_ton;
	boxes = 1 / metric_tons;

	cout.precision(9);
	cout << "Weight in metric tons: " << metric_tons << endl;
	cout.precision(1);
	cout << "Boxes to make one metric ton: " << boxes << endl; 

	cin >> boxes;

	return 0;
}