fork download
  1. #include <iostream>
  2. #include <iomanip> // for output formatting
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7. // Employee profile variables with appropriate data types
  8. string fullName;
  9. int employeeID;
  10. string department;
  11. double salary;
  12. int experience; // in years
  13. bool isFullTime; // true = full-time, false = part-time
  14. char gender; // 'M', 'F', or other
  15.  
  16. // Input section
  17. cout << "Enter full name: ";
  18. getline(cin, fullName);
  19.  
  20. cout << "Enter employee ID (numeric): ";
  21. cin >> employeeID;
  22.  
  23. cin.ignore(); // clear buffer before getline
  24. cout << "Enter department: ";
  25. getline(cin, department);
  26.  
  27. cout << "Enter salary: ";
  28. cin >> salary;
  29.  
  30. cout << "Enter years of experience: ";
  31. cin >> experience;
  32.  
  33. cout << "Is the employee full-time? (1 for Yes, 0 for No): ";
  34. cin >> isFullTime;
  35.  
  36. cout << "Enter gender (M/F/O): ";
  37. cin >> gender;
  38.  
  39. // Output section with formatting
  40. cout << "\n--- Employee Profile ---" << endl;
  41. cout << left << setw(20) << "Full Name" << ": " << fullName << endl;
  42. cout << left << setw(20) << "Employee ID" << ": " << employeeID << endl;
  43. cout << left << setw(20) << "Department" << ": " << department << endl;
  44. cout << left << setw(20) << "Salary" << ": " << fixed << setprecision(2) << salary << endl;
  45. cout << left << setw(20) << "Experience (years)" << ": " << experience << endl;
  46. cout << left << setw(20) << "Full-time Status" << ": " << (isFullTime ? "Yes" : "No") << endl;
  47. cout << left << setw(20) << "Gender" << ": " << gender << endl;
  48.  
  49. return 0;
  50. }
Success #stdin #stdout 0.01s 5316KB
stdin
Brian Moser
2510994514
ECE
50,000,000
43
1
M
stdout
Enter full name: Enter employee ID (numeric): Enter department: Enter salary: Enter years of experience: Is the employee full-time? (1 for Yes, 0 for No): Enter gender (M/F/O): 
--- Employee Profile ---
Full Name           : Brian Moser
Employee ID         : 2147483647
Department          : 
Salary              : 0.00
Experience (years)  : 5355
Full-time Status    : Yes
Gender              :