diff options
author | RossTheRoss <msattr@gmail.com> | 2019-06-25 17:55:13 -0500 |
---|---|---|
committer | RossTheRoss <msattr@gmail.com> | 2019-06-25 17:55:13 -0500 |
commit | 6c83506cb44b1d20f66df404f0b6468b0e291b6b (patch) | |
tree | 8e0475edc2891741862bc9b63844600bdebe6936 /ee1301/wk5/lab4/partner2.cpp | |
parent | M E A N I N G F U L C O M M E N T S (diff) | |
download | homework-6c83506cb44b1d20f66df404f0b6468b0e291b6b.tar homework-6c83506cb44b1d20f66df404f0b6468b0e291b6b.tar.gz homework-6c83506cb44b1d20f66df404f0b6468b0e291b6b.tar.bz2 homework-6c83506cb44b1d20f66df404f0b6468b0e291b6b.tar.lz homework-6c83506cb44b1d20f66df404f0b6468b0e291b6b.tar.xz homework-6c83506cb44b1d20f66df404f0b6468b0e291b6b.tar.zst homework-6c83506cb44b1d20f66df404f0b6468b0e291b6b.zip |
Do a thing:
Diffstat (limited to 'ee1301/wk5/lab4/partner2.cpp')
-rw-r--r-- | ee1301/wk5/lab4/partner2.cpp | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/ee1301/wk5/lab4/partner2.cpp b/ee1301/wk5/lab4/partner2.cpp index 973a44b..2b6bd36 100644 --- a/ee1301/wk5/lab4/partner2.cpp +++ b/ee1301/wk5/lab4/partner2.cpp @@ -1,53 +1,53 @@ -#include <iostream> - -using namespace std; - -string requestName(); -double requestHeight(string fullName); -int requestNumberOfPartners(); -void NotinMain(string fullName[], const int length1, double height[], const int length2); - -int main() -{ - string fullName[2]; //fullName1, fullName2; - double height[2]; //height1, height2; - - fullName[0] = requestName(); - height[0] = requestHeight(fullName[0]); - fullName[1] = requestName(); - height[1] = requestHeight(fullName[1]); - NotinMain(fullName, 2, height, 2); -} - -string requestName() -{ - string name; - cout << "Please enter full name: "; - getline(cin, name); - return name; -} - -double requestHeight(string fullName) -{ - double height; - cout << "Please enter " << fullName << "'s height: "; - cin >> height; - cin.ignore(2, '\n'); // gets rid of \n in the buffer - - return height; -} - -int requestNumberOfPartners() -{ - int numberOfPartners; - cout << "How many partners are there?"; - cin >> numberOfPartners; - - return numberOfPartners; -} - -void NotinMain(string fullName[], const int length1, double height[], const int length2) { - cout << "If " << fullName[0] << " and " << fullName[1] - << " form a human tower, their combined height will be " - << (height[0] + height[1]) << endl; +#include <iostream>
+
+using namespace std;
+
+string requestName();
+double requestHeight(string fullName);
+int requestNumberOfPartners();
+void NotinMain(string fullName[], const int length1, double height[], const int length2);
+
+int main()
+{
+ string fullName[2]; //fullName1, fullName2;
+ double height[2]; //height1, height2;
+
+ fullName[0] = requestName();
+ height[0] = requestHeight(fullName[0]);
+ fullName[1] = requestName();
+ height[1] = requestHeight(fullName[1]);
+ NotinMain(fullName, 2, height, 2);
+}
+
+string requestName()
+{
+ string name;
+ cout << "Please enter full name: ";
+ getline(cin, name);
+ return name;
+}
+
+double requestHeight(string fullName)
+{
+ double height;
+ cout << "Please enter " << fullName << "'s height: ";
+ cin >> height;
+ cin.ignore(2, '\n'); // gets rid of \n in the buffer
+
+ return height;
+}
+
+int requestNumberOfPartners()
+{
+ int numberOfPartners;
+ cout << "How many partners are there?";
+ cin >> numberOfPartners;
+
+ return numberOfPartners;
+}
+
+void NotinMain(string fullName[], const int length1, double height[], const int length2) {
+ cout << "If " << fullName[0] << " and " << fullName[1]
+ << " form a human tower, their combined height will be "
+ << (height[0] + height[1]) << endl;
}
\ No newline at end of file |