fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class undergraduate{
  5.  
  6. public:
  7.  
  8. undergraduate (string fname, string lname, string status, string gradterm, string campus, string major, string minor, string degree, char mi, char gender, int mm, int dd, int yy, int gradyear, int credit, double gpa){
  9.  
  10. fname = fname;
  11. lname = lname;
  12. mi = mi;
  13. mm = mm;
  14. dd = dd;
  15. yy = yy;
  16. major = major;
  17. minor = minor;
  18. degree = degree;
  19. gradyear = gradyear;
  20. gradterm = gradterm;
  21. status = status;
  22. campus = campus;
  23. gender = gender;
  24. credit = credit;
  25. gpa = gpa;
  26. }
  27.  
  28. // a mutator method for full name of student
  29.  
  30. void setFullName(string f, char m, string l){
  31.  
  32. //reassign values to fname, lname, and mi
  33.  
  34. f = fname;
  35. l = lname;
  36. m = mi;
  37. }
  38. // a mutator method for birthday
  39.  
  40. void setBday (int m, int d, int y){
  41. mm = m;
  42. dd = d;
  43. yy = y;
  44. }
  45.  
  46. // a mutator method for data member gender
  47.  
  48. bool setgender(char g){
  49.  
  50. //reassign value to gender and validate assignment
  51.  
  52. bool validate = false;
  53.  
  54. if ( g == 'm' || g == 'M' || g == 'f' || g == 'F'){
  55. gender = g;
  56. validate = true;
  57. }
  58. return (validate);
  59. }
  60.  
  61. //a mutator method for data member status
  62.  
  63. bool setstatus(string s){
  64.  
  65. //reassign value to status and validate assignment
  66.  
  67. bool validate= false;
  68.  
  69. if ( s == "Active" || s == "active" || s == "Withdrawn" || s == "withdrawn" || s == "Sabbatical" || s == "sabbatical" || s == "graduated" || s == "Graduated"){
  70. status = s;
  71. validate = true;
  72. }
  73. return (validate);
  74. }
  75.  
  76. //a mutator method for data member gradterm
  77.  
  78. bool setgradterm(string t){
  79.  
  80. //reassign value to gradterm and validate
  81.  
  82. bool validate = false;
  83. if ( t == "Fall" || t == "fall" || t == "Spring" || t == "spring"){
  84. gradterm = t;
  85. validate = true;
  86. }
  87.  
  88. return (validate);
  89. }
  90.  
  91. // a mutator method for data member gradyear
  92.  
  93. bool setgradyear(int y){
  94.  
  95. //reassign value to gradyear and validate
  96.  
  97. bool validate = false;
  98. if ( y > 2016 && y < 2020){
  99. gradyear = y;
  100. validate = true;
  101. }
  102.  
  103. return (validate);
  104. }
  105.  
  106. // a mutator method for data member campus
  107.  
  108. bool setcampus(string c){
  109.  
  110. //reassign value to campus and validate
  111.  
  112. bool validate = false;
  113. if ( c == "RH" || c == "rh" || c == "rH" || c == "Rh"|| c == "LC" || c == "lc" || c == "Lc" || c == "lC" || c == "WC" || c == "wc" || c == "wC" || c == "Wc"){
  114. campus = c;
  115. validate = true;
  116. }
  117.  
  118. return (validate);
  119. }
  120.  
  121. // a mutator method for data members major, minor, and degree
  122.  
  123. void setgradinfo(string m1, string m2, string d){
  124.  
  125. //reassign value to major, minor, and degree
  126.  
  127. major = m1;
  128. minor = m2;
  129. degree = d;
  130. }
  131.  
  132. // a mutator method for data member credit
  133.  
  134. void setcredit(int c){
  135.  
  136. //reassign value to credit
  137.  
  138. credit = c;
  139. }
  140.  
  141. //a mutator method for a data member gpa
  142.  
  143. bool setgpa(double G){
  144.  
  145. //reassign value to gpa and validate
  146.  
  147. bool validate = false;
  148. if ( G > 1.0 && G <= 4.0){
  149. gpa = G;
  150. validate = true;
  151. }
  152.  
  153. return (validate);
  154. }
  155.  
  156. // a method to populate the data members for fullname through user input
  157.  
  158. void inputFullName(string f, char m, string l){
  159. cout << "Please enter your full name." << endl;
  160. cin >> f;
  161. cin >> m;
  162. cin >> l;
  163. }
  164. // a method to populate the data members for birthday through user input
  165. void inputBday (int m, int d, int y){
  166. char slash;
  167. cout << "Enter your birthday (mm/dd/yy): ";
  168. cin >> m >> slash >> d >> slash >> y;
  169. }
  170. // method to populate the data member of gender through user input
  171.  
  172. void inputgender(){
  173. char g;
  174. do {
  175. cout << "Please state your gender. If you are male, type m. If you are female, type f." << endl;
  176. cin >> g;
  177. } while (!setgender(g));
  178. }
  179.  
  180. //method to populate the data member of status through user input
  181.  
  182. void inputstatus(){
  183. string s;
  184. do{
  185.  
  186. cout << "Please enter your status. Type in one of the following (Active/Graduated/Withdrawn/Sabbatical): ";
  187. cin >> s;
  188. } while (!setstatus(s));
  189. }
  190.  
  191. // a method to populate the data member gradterm through user input
  192.  
  193. void inputgradterm(){
  194. string t;
  195. do{
  196. cout << "Please enter your expected graduation term. Type in (Fall/Spring): ";
  197. cin >> t;
  198. }while(!setgradterm(t));
  199. }
  200.  
  201. //a method to populate the data member gradyear though user input
  202.  
  203. void inputgradyear(){
  204. int y;
  205. do{
  206. cout << "Please enter your expected graduation year." << endl;
  207. cin >> y;
  208. } while (!setgradyear(y));
  209. }
  210.  
  211. // a method to populate the data member campus through user input
  212.  
  213. void inputcampus(){
  214. string c;
  215. do{
  216. cout << "Please enter the campus you are enrolled in." << endl;
  217. cin >> c;
  218. }while(!setcampus(c));
  219. }
  220.  
  221. // a method to populate the data members major, minor, degree through user input
  222.  
  223. void inputgradinfo(string m1, string m2, string d){
  224. cout << "Please enter your major, if you are undeclared, type undeclared." << endl;
  225. cin >> m1;
  226. cout << "Please enter your minor, if you do not have a minor, type none." << endl;
  227. cin >> m2;
  228. cout << "Please state whether you are getting a BS or BA degree." << endl;
  229. cin >> d;
  230. }
  231.  
  232. // a method to populate the data member for credit
  233.  
  234. void inputcredit(){
  235. int c;
  236. cout << "Please enter your number of credits." << endl;
  237. cin >> c;
  238. }
  239. void inputgpa(){
  240. double G;
  241. do{
  242. cout << "Please enter your GPA." << endl;
  243. cin >> G;
  244. }while (!setgpa(G));
  245. }
  246.  
  247.  
  248. // a method to input all the data members
  249.  
  250. void input(){
  251. inputFullName("Ryan", 'D', "Flores");
  252. inputBday(11, 21, 1996);
  253. inputgender();
  254. inputstatus();
  255. inputgradterm();
  256. inputgradyear();
  257. inputcampus();
  258. inputgradinfo("Compsci", "None", "BS");
  259. inputcredit();
  260. inputgpa();
  261. }
  262.  
  263. string getFullName(){
  264. return fname;
  265. return mi;
  266. return lname;
  267.  
  268. int getBday(){
  269. return mm;
  270. return dd;
  271. return yy;
  272. }
  273.  
  274. char getgender(){
  275. return gender;
  276. }
  277.  
  278. string getstatus(){
  279. return status;
  280. }
  281.  
  282. string getgradterm(){
  283. return gradterm;
  284. }
  285.  
  286. int getgradyear(){
  287. return gradyear;
  288. }
  289. string getgradinfo(){
  290. return major;
  291. return minor;
  292. return degree;
  293. }
  294.  
  295. int getcredit(){
  296. return credit;
  297. }
  298.  
  299. double getgpa(){
  300. return gpa;
  301. }
  302.  
  303. /* void display(){
  304.   cout << getFullName() << endl;
  305.   cout << getBday() << endl;
  306.   cout << getgender() << endl;
  307.   cout << getstatus() <<endl;
  308.   cout << getgradterm() << endl;
  309.   cout << getgradyear() << endl;
  310.   cout << getgradinfo() << endl;
  311.   cout << getcredit() << endl;
  312.   cout << getgpa() << endl;
  313.   }
  314.   */
  315.  
  316. private:
  317.  
  318. string fname, lname, status, gradterm, campus, major, minor, degree;
  319. char mi, gender;
  320. int mm, dd, yy, gradyear, credit;
  321. double gpa;
  322.  
  323. };
  324.  
  325. int main (){
  326.  
  327. undergraduate s1(); //initializing values to s1
  328.  
  329.  
  330.  
  331. }
  332.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:331:5: error: expected '}' at end of input
     }
     ^
prog.cpp: In member function 'void undergraduate::setFullName(std::string, char, std::string)':
prog.cpp:34:13: error: 'fname' was not declared in this scope
         f = fname;
             ^
prog.cpp:35:13: error: 'lname' was not declared in this scope
         l = lname;
             ^
prog.cpp:36:13: error: 'mi' was not declared in this scope
         m = mi;
             ^
prog.cpp: In member function 'void undergraduate::setBday(int, int, int)':
prog.cpp:41:9: error: 'mm' was not declared in this scope
         mm = m;
         ^
prog.cpp:42:9: error: 'dd' was not declared in this scope
         dd = d;
         ^
prog.cpp:43:9: error: 'yy' was not declared in this scope
         yy = y;
         ^
prog.cpp: In member function 'bool undergraduate::setgender(char)':
prog.cpp:55:13: error: 'gender' was not declared in this scope
             gender = g;
             ^
prog.cpp: In member function 'bool undergraduate::setstatus(std::string)':
prog.cpp:70:13: error: 'status' was not declared in this scope
             status = s;
             ^
prog.cpp: In member function 'bool undergraduate::setgradterm(std::string)':
prog.cpp:84:13: error: 'gradterm' was not declared in this scope
             gradterm = t;
             ^
prog.cpp: In member function 'bool undergraduate::setgradyear(int)':
prog.cpp:99:13: error: 'gradyear' was not declared in this scope
             gradyear = y;
             ^
prog.cpp: In member function 'bool undergraduate::setcampus(std::string)':
prog.cpp:114:13: error: 'campus' was not declared in this scope
             campus = c;
             ^
prog.cpp: In member function 'void undergraduate::setgradinfo(std::string, std::string, std::string)':
prog.cpp:127:9: error: 'major' was not declared in this scope
         major = m1;
         ^
prog.cpp:128:9: error: 'minor' was not declared in this scope
         minor = m2;
         ^
prog.cpp:129:9: error: 'degree' was not declared in this scope
         degree = d;
         ^
prog.cpp: In member function 'void undergraduate::setcredit(int)':
prog.cpp:138:9: error: 'credit' was not declared in this scope
         credit = c;
         ^
prog.cpp: In member function 'bool undergraduate::setgpa(double)':
prog.cpp:149:13: error: 'gpa' was not declared in this scope
             gpa = G;
             ^
prog.cpp: In member function 'std::string undergraduate::getFullName()':
prog.cpp:264:16: error: 'fname' was not declared in this scope
         return fname;
                ^
prog.cpp:265:16: error: 'mi' was not declared in this scope
         return mi;
                ^
prog.cpp:266:16: error: 'lname' was not declared in this scope
         return lname;
                ^
prog.cpp:268:22: error: a function-definition is not allowed here before '{' token
         int getBday(){
                      ^
prog.cpp:274:25: error: a function-definition is not allowed here before '{' token
         char getgender(){
                         ^
prog.cpp:278:27: error: a function-definition is not allowed here before '{' token
         string getstatus(){
                           ^
prog.cpp:282:29: error: a function-definition is not allowed here before '{' token
         string getgradterm(){
                             ^
prog.cpp:286:26: error: a function-definition is not allowed here before '{' token
         int getgradyear(){
                          ^
prog.cpp:289:29: error: a function-definition is not allowed here before '{' token
         string getgradinfo(){
                             ^
prog.cpp:295:24: error: a function-definition is not allowed here before '{' token
         int getcredit(){
                        ^
prog.cpp:299:24: error: a function-definition is not allowed here before '{' token
         double getgpa(){
                        ^
prog.cpp:316:5: error: expected primary-expression before 'private'
     private:
     ^
prog.cpp: At global scope:
prog.cpp:331:5: error: expected unqualified-id at end of input
     }
     ^
stdout
Standard output is empty