setw - cout<< setw(12<< teaspoonsOfSugar<<"...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> #include <iomanip> using namespace std ; int main() { double cansPerWeek = 0.0 ; cout << "How many cans of soda are consumed in a week? " ; cin >> cansPerWeek ; double teaspoonsOfSugar = 10 * cansPerWeek ; double tablespoonsOfSugar = teaspoonsOfSugar / 3 ; double cupsOfSugar = tablespoonsOfSugar / 16 ; double ouncesOfSugar = cupsOfSugar * 10.8 ; double poundsOfSugarPerWeek = ouncesOfSugar / 16 ; double poundsOfSugarPerYear = poundsOfSugarPerWeek * 52 ; cout.precision(2); cout.setf(ios::fixed); cout << setw(12) << cansPerWeek << " cans of soda per week" << endl ;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout << setw(12) << teaspoonsOfSugar << " teaspoons of sugar per week." << endl ; cout << setw(12) << tablespoonsOfSugar << " tablespoons of sugar per week." << endl ; cout << setw(12) << cupsOfSugar << " cups of sugar per week." << endl ; cout << setw(12) << ouncesOfSugar << " ounces of sugar per week." << endl ; cout << setw(12) << poundsOfSugarPerWeek << " pounds of sugar per week." << endl ; cout << setw(12) << poundsOfSugarPerYear << " pounds of sugar per year. " << endl ; return 0 ; }...
View Full Document

This note was uploaded on 10/28/2010 for the course CSCI 1113 taught by Professor Staff during the Spring '08 term at Minnesota.

Ask a homework question - tutors are online