-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComputerDiagnosis.cpp
More file actions
67 lines (58 loc) · 1.78 KB
/
Copy pathComputerDiagnosis.cpp
File metadata and controls
67 lines (58 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
using namespace std;
char getYesNo(const string& prompt) {
char answer;
while (true) {
cout << prompt;
cin >> answer;
if (answer == 'y' || answer == 'Y' || answer == 'n' || answer == 'N')
return answer;
cout << "Invalid input. Please enter Y/y or N/n only.\n";
cin.clear();
cin.ignore(10000, '\n');
}
}
void diagnose() {
char errorMsg = getYesNo("Is there an error message? (Y/N): ");
if (errorMsg == 'y' || errorMsg == 'Y') {
cout << "Perform Diagnosis.\nGo to Power Check.\n";
} else {
cout << "Computer is in good condition. Return.\n";
}
}
void powerSupplyCheck() {
char powerLight = getYesNo("Is power light ON? (Y/N): ");
if (powerLight == 'y' || powerLight == 'Y') {
cout << "Find specialist. Return.\n";
return;
}
char pluggedIn = getYesNo("Is power plugged into wall? (Y/N): ");
if (pluggedIn == 'y' || pluggedIn == 'Y') {
cout << "Find specialist. Return.\n";
} else {
cout << "Plug power into the wall. Return.\n";
}
}
void powerCheck() {
char computerOn = getYesNo("Is computer ON? (Y/N): ");
if (computerOn == 'y' || computerOn == 'Y') {
cout << "Error handling starts.\n";
} else {
cout << "Checking power supply...\n";
powerSupplyCheck();
}
}
int main() {
cout << "Initialization Process:\n";
char computerOn = getYesNo("Is computer ON? (Y/N): ");
if (computerOn == 'y' || computerOn == 'Y') {
cout << "Computer is ON. Proceeding to error check...\n";
diagnose();
} else {
cout << "Computer is OFF. Proceeding to power check...\n";
powerCheck();
diagnose();
}
cout << "Process ended.\n";
return 0;
}