#include <iostream.h>
#include <stdlib.h>
int main ( )
{
int choice;
cout << "Computer Repair" << endl;
cout << "\n Does your ailing computer beeps multiable times at startup?" << endl;
cin >> choice;
switch (choice)
{
case Yes: cout << "\n Does the hard drive spin?" << endl; break;
cin >> choice;
switch (choice)
case Yes: cout << "\n Contact tech support. << endl; break;
}
case No: cout << "\n221 Red 160 Green 221 Blue\n" << endl; break;
default : cout << "\nInvalid Selection." << endl; break;
}
cout <<
case 3: cout << "\n255 Red 105 Green 180 Blue\n" << endl; break;
case 4: cout << "\n172 Red 34 Green 34 Blue\n" << endl; break;
case 5: cout << "\n255 Red 127 Green 80 Blue\n" << endl; break;
case 6: cout << "\n240 Red 230 Green 140 Blue\n" << endl; break;
default : cout << "\nInvalid Selection." << endl; break;
}
system("Pause");
return (0);
}
i can't get it to work
Based on the code provided, it seems that there are a few errors and issues that need to be addressed in order to get it to work.
1. Library inclusion: The correct library inclusion for standard input/output in C++ is `<iostream>`, not `<iostream.h>`. Similarly, `<stdlib.h>` should be replaced with `<cstdlib>`.
2. 'choice' variable declaration: The 'choice' variable should be declared before using it in the code.
3. Missing semicolon: There is a missing semicolon after the line `"Contact tech support."`.
4. Unidentified values: The code uses undefined values, such as `Yes` and `No` in the `switch` statements. These values need to be defined or replaced with appropriate conditions.
5. 'cout' before 'switch': There is an extra `cout` statement before each `switch` statement, which should be removed.
6. `default` cases: The `default` cases in both `switch` statements are missing the corresponding `cout` statements.
Here's the corrected code:
```cpp
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
int choice;
cout << "Computer Repair" << endl;
cout << "\nDoes your ailing computer beep multiple times at startup?" << endl;
cin >> choice;
switch (choice) {
case 1:
cout << "\nDoes the hard drive spin?" << endl;
cin >> choice;
switch (choice) {
case 1:
cout << "\nContact tech support." << endl;
break;
default:
cout << "\nInvalid Selection." << endl;
break;
}
break;
case 2:
cout << "\n221 Red 160 Green 221 Blue\n" << endl;
break;
case 3:
cout << "\n255 Red 105 Green 180 Blue\n" << endl;
break;
case 4:
cout << "\n172 Red 34 Green 34 Blue\n" << endl;
break;
case 5:
cout << "\n255 Red 127 Green 80 Blue\n" << endl;
break;
case 6:
cout << "\n240 Red 230 Green 140 Blue\n" << endl;
break;
default:
cout << "\nInvalid Selection." << endl;
break;
}
system("Pause");
return 0;
}
```
Try using this corrected code, and it should work properly.