fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9. char patientName;
  10. int age;
  11. double tempCelsius, tempFahrenheit;
  12.  
  13. // Header Display
  14. cout << "===========================================" << endl;
  15. cout << " ADULT FEVER TEMPERATURE CHECKER " << endl;
  16. cout << "===========================================" << endl;
  17.  
  18. // User Inputs: Personal Information
  19. cout << "Enter Patient Name: ";
  20. cin >> patientName;
  21.  
  22. cout << "Enter Patient Age: ";
  23. cin >> age;
  24.  
  25. // Direct Celsius Input
  26. cout << "Enter Thermometer Temperature (in °C): ";
  27. cin >> tempCelsius;
  28.  
  29. // Automatic Conversion to Fahrenheit: F = (C * 9/5) + 32
  30. tempFahrenheit = (tempCelsius * 9.0 / 5.0) + 32.0;
  31.  
  32. // Display Summary Header
  33. cout << "\n===========================================" << endl;
  34. cout << " DIAGNOSIS RESULT " << endl;
  35. cout << "===========================================" << endl;
  36. cout << "Patient Name : " << patientName << endl;
  37. cout << "Patient Age : " << age << endl;
  38.  
  39. // Formatting to 1 decimal place with C / F display
  40. cout << fixed << setprecision(1);
  41. cout << "Recorded Temp: " << tempCelsius << " °C / " << tempFahrenheit << " °F" << endl;
  42. cout << "-------------------------------------------" << endl;
  43.  
  44. // Main IF / ELSE IF / ELSE Evaluation (Based on Celsius input)
  45. if (tempCelsius < 37.3) {
  46. cout << "Fever Level : Normal Temperature" << endl;
  47. cout << "Range : Below 37.3 °C / Below 99.1 °F" << endl;
  48. cout << "Advice : Body temperature is within normal limits." << endl;
  49. }
  50. else if (tempCelsius <= 38.0) {
  51. cout << "Fever Level : Low-grade fever" << endl;
  52. cout << "Range : 37.3 °C - 38.0 °C / 99.1 °F - 100.4 °F" << endl;
  53. cout << "Advice : Rest well, stay hydrated, and monitor your symptoms." << endl;
  54. }
  55. else if (tempCelsius <= 39.0) {
  56. cout << "Fever Level : Moderate-grade fever" << endl;
  57. cout << "Range : 38.1 °C - 39.0 °C / 100.6 °F - 102.2 °F" << endl;
  58. cout << "Advice : Take fever reducer medication if needed and get plenty of rest." << endl;
  59. }
  60. else if (tempCelsius <= 41.0) {
  61. cout << "Fever Level : High-grade fever" << endl;
  62. cout << "Range : 39.1 °C - 41.0 °C / 102.4 °F - 105.8 °F" << endl;
  63. cout << "Advice : Consult a healthcare professional if fever persists." << endl;
  64. }
  65. else {
  66. cout << "Fever Level : Hyperthermia" << endl;
  67. cout << "Range : Above 41.0 °C / Above 105.8 °F" << endl;
  68. cout << "Advice : SEEK EMERGENCY MEDICAL ATTENTION IMMEDIATELY!" << endl;
  69. }
  70.  
  71. cout << "===========================================" << endl;
  72.  
  73. return 0;
  74. }
  75.  
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
===========================================
     ADULT FEVER TEMPERATURE CHECKER       
===========================================
Enter Patient Name: Enter Patient Age: Enter Thermometer Temperature (in °C): 
===========================================
             DIAGNOSIS RESULT              
===========================================
Patient Name : 
Patient Age  : 0
Recorded Temp: 0.0 °C / 32.0 °F
-------------------------------------------
Fever Level : Normal Temperature
Range       : Below 37.3 °C / Below 99.1 °F
Advice      : Body temperature is within normal limits.
===========================================