Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********************************************************************
- * Lab 7 : Functions.cpp
- *
- * Author: Alissa McGill
- * alm161@zips.uakron.edu
- *
- * Purpose: Introduce concepts of functions
- *
- ********************************************************************/
- #include <iostream>
- #include <string>
- using namespace std;
- // prototypes
- int input_an_int();
- void print_sequence(int);
- string rate_type(int);
- int main()
- {
- int n, t, r; // for user input
- cout << "Sequence from 0 to end\n";
- n = input_an_int();
- print_sequence(n);
- cout << endl;
- cout<<"Type in a commute time (in minutes): "<<endl;
- t = input_an_int();
- rate_time(t);
- cout<<t<< "minutes seems" <<rate_time(t)<<endl;
- return 0;
- }
- // Get user input and try to interpret it as an integer.
- int input_an_int() {
- int num = 0;
- cout << "Type an integer, then press enter:\n>" << flush;
- cin >> num;
- cin.ignore(20000, '\n');
- return num;
- }
- void print_sequence(int x)
- {
- int n;
- n=x;
- cout << "Sequence from 0 to " << x<< ": ";
- for(int i =0; i<=x ; ++i)
- {
- cout << i << " ";
- }
- }
- string rate_time(int r)
- {
- int t;
- t=r;
- if (r<=30)
- t='short';
- else if(r>30 && r<60)
- t='medium';
- else if(r>=60)
- t='long';
- else
- t='impossible';
- return t;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement