bartborzeckiLabWeek4

bartborzeckiLabWeek4 - ":" ; temp...

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

View Full Document Right Arrow Icon
Bart Borzecki CIS 170 k Instructor: Gross Week 4 Lab (Extra Credit) Lab4 Code //Lab4 for CIS170 – Bart Borzecki #include <iostream> using namespace ::std; int Temp(); void AverageTemp( int * sum, int * num); int main() { int temp = 0; int count = 0; int num = 1; double averageTemp = 0.0; int sum = 0; char answer; do { cout << "How many cities will you use: " ; cin >> count; while (count < 1) { cout << "Error! Invalid Input!" << endl; cout << "How many cities will you use: " ; cin.clear(); cin.ignore(); cin >> count; } num = 1; sum = 0; while (num <= count) { cout << "Please enter Temp " << num <<
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
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: &quot;:&quot; ; temp = Temp(); sum += temp; num ++; } AverageTemp(&amp;sum, &amp;count); do { cout &lt;&lt; &quot;Do you want to do it again? (Y or N): &quot; ; cin &gt;&gt; answer; answer = toupper(answer); } while (answer != 'Y' &amp;&amp; answer != 'N' ); } while (answer == 'Y' ); } void AverageTemp( int * sum, int * count) { double averageTemp; averageTemp = static_cast &lt; double &gt;(*sum) / static_cast &lt; double &gt;(*count); cout &lt;&lt; &quot;The average is: &quot; &lt;&lt; averageTemp &lt;&lt; endl; } int Temp() { int temp; cin &gt;&gt; temp; return temp; } Lab4 Output...
View Full Document

Page1 / 3

bartborzeckiLabWeek4 - &amp;amp;quot;:&amp;amp;quot; ; temp...

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

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