lab7 - customer[value]=ABSENT; beds++; for (int j=0;...

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; int beds; int leaver; string person; int main(){ enum Status {TANNING, WAITING, ABSENT}; Status customer[26]; for (int i=0; i<26; i++) customer[i]=ABSENT; cin>> beds; cout << endl; while (beds!=0){ cin >> person; for (int n=0; n<person.length(); n++){ int value = person[n] - 'A'; if (customer[value]==ABSENT){ if (beds!=0){ customer[value]=TANNING; beds--; cout << beds << endl; } else customer[value]=WAITING; } if (beds==0){ if (customer[value]==TANNING){
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: customer[value]=ABSENT; beds++; for (int j=0; j&lt;26; j++){ if (customer[j]==WAITING){ customer[j]=TANNING; beds--; cout &lt;&lt; &quot;cow&quot; &lt;&lt; endl; } } } if (customer[value]==WAITING){ customer[value]=ABSENT; leaver++; cout &lt;&lt;leaver &lt;&lt; endl; } } } if (leaver==0) cout &lt;&lt; &quot;All customers tanned successfully&quot; &lt;&lt; endl; else cout &lt;&lt; leaver &lt;&lt; &quot; customer(s) walked away.&quot; &lt;&lt; endl; for (int h=0; h&lt;26; h++) customer[h]=ABSENT; int leaver=0; cin &gt;&gt; beds; } }...
View Full Document

Page1 / 2

lab7 - customer[value]=ABSENT; beds++; for (int j=0;...

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