I'm having problems with this program that i'm trying to write for one of my classes. I'm probably going to get made fun of like last time I posted, but i'm sure it won't be too difficult for you guys to figure the problem out, but i'm kind of new to programming. thanks!
THis is what I get for output when I run it typing "./hw05 < warworlds.txt"Code:#include <iostream> #include <iomanip> using namespace std; void print_header(); int main() { int vowel, odd, quote, period, rest, total; char file; print_header(); do { switch (file) { case 'A': case 'a': case 'E': case 'e': case 'I': case 'i': case 'O': case 'o': case 'U': case 'u': case 'Y': case 'y': vowel++; break; case '1': case '3': case '5': case '7': case '9': odd++; break; case '\"': case '\'': quote++; break; case '.': period++; break; default: rest++; } } while (cin.eof()); cout << "Category " << "Count \n" << "========== " << "=============" << endl; cout << "quotes " << quote << endl; cout << "vowels " << vowel << endl; cout << "periods " << period << endl; cout << "oddDigits " << odd << endl; cout << "allTheRest " << rest << endl; total = (vowel+quote+period+odd+rest); cout << "total " << total << endl; return 0; } /* * Name: print_header * Purpose: Display header * Receive: Nothing * Return: Header */ void print_header() { cout << "Name: mygly\n" << "Course: CPS 180 (45911)\n" << "Assignment: Homework 9\n" << "Purpose: count all vowels, quotes, periods, odd integers and non-whitespace and display them in a table format to the user\n"; }
Output:
Name: Mygly
Course: CPS 180 (45911)
Assignment: Homework 9
Purpose: count all vowels, quotes, periods, odd integers and non-whitespace and display them in a table format to the user
Category Count
========== =============
quotes 0
vowels 0
periods -12847528
oddDigits 0
allTheRest 68017
total -12779511
As you can tell I'm have a problem... Thanks



LinkBack URL
About LinkBacks


