calc lowest arrays eas 230

calc lowest arrays eas 230 - } default: { cout...

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

View Full Document Right Arrow Icon
#include <iostream> using namespace std; // functions int presentMenu( ); double getLowestLab( ); // define lab variables OUTSIDE of main as GLOBAL variables double lab1 = -1, lab2 = -1, lab3 = -1; int main () { // variables int userChoice = 99; double lowestLab = 100.0; while (true) { // repeat until quit userChoice = presentMenu( ); switch (userChoice) { case 1: { cout << "Enter Lab 1 score: "; cin >> lab1; break; } case 2: { cout << "Enter Lab 2 score: "; cin >> lab2; break; } case 3: { cout << "Enter Lab 3 score: "; cin >> lab3; break; } case 4: { lowestLab = getLowestLab( ); cout << endl << "Low Lab: " << lowestLab << endl; break; }
Background image of page 1

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

View Full DocumentRight Arrow Icon
case 5: { return 0;
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: } default: { cout &lt;&lt; &quot;Invalid entry &quot; &lt;&lt; endl &lt;&lt; endl; } } } // run forever } int presentMenu( ) { int selection = -1; cout &lt;&lt; &quot;*************&quot; &lt;&lt; endl; cout &lt;&lt; &quot;1. Enter Lab1&quot; &lt;&lt; endl; cout &lt;&lt; &quot;2. Enter Lab2&quot; &lt;&lt; endl; cout &lt;&lt; &quot;3. Enter Lab3&quot; &lt;&lt; endl; cout &lt;&lt; &quot;4. Get Lowest Lab&quot; &lt;&lt; endl; cout &lt;&lt; &quot;5. Quit&quot; &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; &quot;Enter choice, 1-5: &quot;; cin &gt;&gt; selection; cout &lt;&lt; endl; return selection; } double getLowestLab( ) { double minimum = 100; if (lab1 &lt; minimum) { minimum = lab1; } if (lab2 &lt; minimum) { minimum = lab2; } if (lab3 &lt; minimum) { minimum = lab3; } return minimum; }...
View Full Document

This document was uploaded on 12/05/2011.

Page1 / 3

calc lowest arrays eas 230 - } default: { cout...

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