AIVQ2 - if(input=='n'){ char1='n'; return '0'; } else...

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

View Full Document Right Arrow Icon
#include <iostream> #include <fstream> using namespace std; class neat { private: char char1,char2,char3,char4; public: neat(void); char update(char input); }; int main(void) { ofstream fout("neat.out"); ifstream fin("neat.in"); neat x; char input; char output; while(fin >> input) { output = x.update(input); fout << output; } fout.close(); system("notepad neat.out"); return 0; } neat::neat(){ char char1(0),char2(0),char3(0),char4(0); } char neat::update(char input){
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if(input=='n'){ char1='n'; return '0'; } else if(input=='e'){ char2='e'; return '0'; } else if(input=='a'){ char3='a'; return '0'; } else if(input=='t'){ char4='t'; if(char1=='n'&amp;&amp;char2=='e'&amp;&amp;char3=='a'){ char1='0',char2='0',char3='0',char4='0'; return '1'; } else{ char1='0',char2='0',char3='0',char4='0'; return '0'; } } else{ char1='0',char2='0',char3='0',char4='0'; return '0'; } }...
View Full Document

Ask a homework question - tutors are online