Advertisement
Guest User

cpp

a guest
Dec 20th, 2017
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. using namespace std;
  4. string team;
  5. string name1;
  6. string name2;
  7. string name3;
  8. string tmp;
  9. int ID1;
  10. int ID2;
  11. int ID3;
  12. int num;
  13.  
  14. void NAME(){
  15. int i ;
  16. i = 0;
  17. while(i<4){
  18. cout << i << endl;
  19. if(i==0){
  20. cout << "Please enter your team: " << endl;
  21. getline(cin,tmp);
  22. team = tmp;
  23. } //if
  24. else{
  25. cout << "Please enter your name: " << endl;
  26. getline(cin,tmp);
  27. if(i==1)
  28. name1 = tmp;
  29. else if(i==2)
  30. name2 = tmp;
  31. else if(i==3)
  32. name3 = tmp;
  33. } //else
  34. i++;
  35. }
  36.  
  37. cout << "*****Print Name*****" << endl;
  38. cout << team << endl;
  39. cout << name1 << endl;
  40. cout << name2 << endl;
  41. cout << name3 << endl;
  42. cout << "*****End Print*****" << endl;
  43.  
  44. }
  45.  
  46. void ID() {
  47. int i = 1;
  48. cout << "*****Input ID*****" << endl;
  49. while(i<4){
  50. cout << "** Please Enter Member " << i << " ID **" << endl;
  51. cin >> num ;
  52. if(i==1)
  53. ID1 = num;
  54. else if(i==2)
  55. ID2 = num;
  56. else if(i==3)
  57. ID3 = num;
  58. i++;
  59. } //while
  60. num = num + ID1 + ID2 + ID3 ;
  61. cout << "** Please Enter Command **" << endl;
  62. cin >> tmp;
  63. if(tmp == "p"){
  64. cout << "*****Print Team Member ID and ID Summation*****" << endl;
  65. cout << ID1 << endl << ID2 << endl << ID3 << endl;
  66. cout << "ID Summation = " << num << endl;
  67. cout << "*****End Print*****" << endl;
  68. } //if()
  69.  
  70. } //ID()
  71. int main()
  72. {
  73. string input;
  74. while(true){
  75. cout <<" Press 0 to quit" << endl;
  76. cout << "Press 1 to do Function 1(NAME)" << endl;
  77. cout << "Press 2 to do Function 2(ID)" << endl;
  78. cout << "Press 3 to do Main Function" << endl;
  79. getline(cin, input);
  80. if(input =="0")
  81. break;
  82. else if(input =="1")
  83. NAME();
  84. else if(input =="2")
  85. ID();
  86. else if(input =="3"){
  87. cout << "*****Print All*****" << endl;
  88. cout << team << endl ;
  89. cout << ID1 << " " << name1 << endl;
  90. cout << ID2 << " " << name2 << endl;
  91. cout << ID3 << " " << name3 << endl;
  92. cout << "ID Summation = " << num << endl;
  93. cout << "*****End Print*****" << endl;
  94. }
  95. else
  96. cout << "Please try again." << endl;
  97. }
  98. return 0;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement