assignment21 - cin.ignore total = value break case...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> #include <string> # using namespace std; u int main() { double total = 0, counter = 0; char sign, X = 0; double value; for (;;) { do { cout << "Current total is " << total << endl; cout << "Enter an operation: + - * / (or enter X to exit):"; cin >> sign; } while( (sign != '+') && (sign != '-') && (sign != '*') && (sign != '/') && (sign != 'X')); ( switch (sign) { case 'X': return 0; case '+': cout << "Enter a number: "; cin >> value;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cin.ignore(); total += value; break; case '-': cout << "Enter a number: "; cin >> value; cin.ignore(); total -= value; break; case '*': cout << "Enter a number: "; cin >> value; cin.ignore(); total *= value; break; case '/': cout << "Enter a number: "; cin >> value; cin.ignore(); c if (value != 0) total /= value; else { cout << "Can not divide by zero! " << endl; } break; default: return (0); } } }...
View Full Document

This note was uploaded on 01/11/2010 for the course CMPSC 101 taught by Professor Drobish,renee during the Summer '07 term at Penn State.

Page1 / 2

assignment21 - cin.ignore total = value break case...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online