My name is Alana and I am taking C++ for summer. This is my first year of programming and today I got my first homework. It is due tonight at 11:59 PM but I have been doing my homework since 1 PM. But it's not working. Could you guys please help me debug my program? Thank you so much:
// DieselEngine_Diagnostic
// This program will aid costumers on troubleshooting their diesel engine
#include <iostream>
using namespace std;
int main()
{
int let, light, met, vel, pressure, k, g, r, a;
cout << "Welcome! I am here to help you troubleshoot your engine." <<endl;
cout << "Type lowercase k to continue ";
cin >> let;
{
if (let == k)
{
cout << "I will glady assist you with your problems." <<endl;
cout << "First, let us check your status light. "<<endl;
cout << "If it is green, type g." <<endl;
cout << "If it is red, type r." <<endl;
cout << "If it is amber, type a." <<endl;
cin >> light;
{
if (light == g)
cout << "Your engine is fine! Goodbye. "<<endl;
else if (light == r)
{
cout << "Let us check the meter. Type in the number found on the meter:" <<endl;
cin >> met;
{
if (met < 50)
{
cout << "Describe the test pressure."<<endl;
cout << "If it's normal, type n." <<endl;
cout << "If it's high, type h." <<endl;
cout << "If it's low, type l." <<endl;
cin >> pressure;
{
if (pressure == 'n')
cout << "Refer to motor service manual.";
else if (pressure == 'h')
cout << "Refer to main line manual.";
else if (pressure == 'l')
cout << "Refer to main line manual.";
}
}
else if (met >= 50)
{
cout << "Let's measure flow velocity at inlet 2-B." <<endl;
cout << "If it's normal, type o." <<endl;
cout << "If it's high or low, type x." <<endl;
cin >> vel;
{
if (vel == 'o')
cout << "Refer to inlet service manual.";
else if (vel == 'x')
cout << "Refer unit for factory service.";
}
}
}
}
else if (light == a)
{
cout <<"Check fuel line service routine." <<endl;
}
if (let == k)
if (light == g)
elseif (light == r)
elseif (light == a)
You have not quoted k g r a so the statement is saying
if let is the same value as k, k is currently null or 0 because its not defined. k is declared as an int above.
To fix these issues, put a quote
1 2 3 4
if (let == 'k')
if (light == 'g')
elseif (light == 'r')
elseif (light == 'a')
Also, all your int variables let,k,g,a etc.. are ints, int stands for integer which means their numbers. You want to user to enter a character not a number.