#include #include //for the i/o manipulator setw ("set width") #include //for class string #include "branch.h" using namespace std; const branchInfo branch::branches[] = { { "Navy", { //Navy Enlisted { "Seaman Recruit", "Seaman Apprentice", "Seaman", "Petty Officer Third Class", "Petty Officer Second Class", "Petty Officer First Class", "Chief Petty Officer", "Senior Chief Petty Officer", "Master Chief Petty Officer" }, //Navy CWO (Chief warrant officer) { "Not used", "Chief Warrant Officer 2", "Chief Warrant Officer 3", "Chief Warrant Officer 4", "Chief Warrant Officer 5" }, //Navy Officer { "Ensign", "Lieutenant Junior Grade", "Lieutenant", "Lieutenant Commander", "Commander", "Captain", "Rear Admiral (Lower Half)", "Rear Admiral (Upper Half)", "Vice Admiral", "Admiral" } } }, { "Army", { //Army Enlisted { "Private", "Private Second Class", "Private First Class", "Specialist", "Sergeant", "Staff Sergeant", "Sergeant First Class", "Master Sergeant", "Sergeant Major" }, //Army CWO (Chief warrant officer) { "Warrant Officer 1", "Chief Warrant Officer 2", "Chief Warrant Officer 3", "Chief Warrant Officer 4", "Chief Warrant Officer 5" }, //Army Officer { "Second Lieutenant", "First Lieutenant", "Captain", "Major", "Lieutenant Colonel", "Colonel", "Brigadier General", "Major General", "Lieutenant General", "General" } } }, { "Marines", { //Marines Enlisted { "Private", "Private Second Class", "Private First Class", "Specialist", "Sergeant", "Staff Sergeant", "Sergeant First Class", "Master Sergeant", "Sergeant Major" }, //Marines CWO (Chief warrant officer) { "Warrant Officer 1", "Chief Warrant Officer 2", "Chief Warrant Officer 3", "Chief Warrant Officer 4", "Chief Warrant Officer 5" }, //Marines Officer { "Second Lieutenant", "First Lieutenant", "Captain", "Major", "Lieutenant Colonel", "Colonel", "Brigadier General", "Major General", "Lieutenant General", "General" } } }, { "Air Force", { //Air Force Enlisted { "Airman Basic", "Airman", "Airman First Class", "Senior Airman", "Staff Sergeant", "Technical Sergeant", "Master Sergeant", "Senior Master Sergeant", "Chief Master Sergeant" }, //Air Force CWO (Chief warrant officer) { "No warrant officers in this branch", "No warrant officers in this branch", "No warrant officers in this branch", "No warrant officers in this branch", "No warrant officers in this branch" }, //Air Force Officer { "Second Lieutenant", "First Lieutenant", "Captain", "Major", "Lieutenant Colonel", "Colonel", "Brigadier General", "Major General", "Lieutenant General", "General" } } }, { "Space Force", { //Space Force Enlisted { "Specialist 1", "Specialist 2", "Specialist 3", "Specialist 4", "Sergeant", "Technical Sergeant", "Master Sergeant", "Senior Master Sergeant", "Chief Master Sergeant" }, //Space Force CWO (Chief warrant officer) { "No warrant officers in this branch", "No warrant officers in this branch", "No warrant officers in this branch", "No warrant officers in this branch", "No warrant officers in this branch" }, //Space Force Officer { "Second Lieutenant", "First Lieutenant", "Captain", "Major", "Lieutenant Colonel", "Colonel", "Brigadier General", "Major General", "Lieutenant General", "General" } } }, { "Coast Guard", { //Coast Guard Enlisted { "Seaman Recruit", "Seaman Apprentice", "Seaman", "Petty Officer Third Class", "Petty Officer Second Class", "Petty Officer First Class", "Chief Petty Officer", "Senior Chief Petty Officer", "Master Chief Petty Officer" }, //Coast Guard CWO (Chief warrant officer) { "Not used", "Chief Warrant Officer 2", "Chief Warrant Officer 3", "Chief Warrant Officer 4", "Chief Warrant Officer 5" }, //Coast Guard Officer { "Ensign", "Lieutenant Junior Grade", "Lieutenant", "Lieutenant Commander", "Commander", "Captain", "Rear Admiral (Lower Half)", "Rear Admiral (Upper Half)", "Vice Admiral", "Admiral" } } } }; branch::branch(int init_b) : b {init_b} { } string branch::getName() const { return branches[b].name; } void branch::print() const { cout << branches[b].name << " Rank Structure\n\n"; struct rankInfo { char initial; string name; }; const rankInfo r[] { //an array of three structures {'E', "Enlisted"}, {'W', "Chief Warrant Officers"}, {'O', "Officers"} }; const size_t n {size(r)}; for (int i {0}; i < n; ++i) { cout << r[i].name << ":\n"; const vector::size_type m {size(branches[b].rank[i])}; for (int j {0}; j < m; ++j) { cout << r[i].initial << "-" << setw(2) << left << j + 1 << " " << branches[b].rank[i][j] << "\n"; } cout << "\n"; } }