Im suppose to read in a file (which it isn't doing) and get numbers form them to see if they pass or fail certain specifications. Can someone help?

the exact specifications are:
The company you work for, Acme Environmental Monitoring, runs sensors to test air quality at different locations. These readings need to be processed to grade the air according to the national air quality standards.

You need to write a program that will read a file of these readings, test them against the standards and output the ratings.

This program will require reading from a data file, doing some logical checking and calculations with the information in that file, and reporting the results.

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

//we have two functions

bool in_compliance(float standard, float first, float second, float third);

string rating(bool ozone, bool no2, bool so2);

int main()
{
	bool ozone_passfail, no2_passfail, so2_passfail;
	string theRating;
	ifstream inFile;
	string fileName;
	float standardPF, ozonePF, no2PF, so2PF;
	string location;
	string ozoneStats;

	

	//Get filename from user
	cout << "Enter the filename of data to process --> ";
	cin >> fileName;

	//Open the file
	inFile.open(fileName.c_str());

		//Check if file opened
	while(!inFile.is_open())	
	{
		cout << "Sorry, that file does not exist!" << endl;
		cout << "Enter the filename of data to process --> ";
		cin >> fileName;
		
	}
	inFile.ignore(1, '\n');
	//Read the location and store in string variable
	getline(inFile, location);
		//Read standard,three sample values and make sure we skip the rest of the line
	inFile.ignore(1, '\n');
	getline(inFile, ozoneStats);

			
	ozone_passfail = in_compliance(standardPF, ozonePF, no2PF, so2PF);
	no2_passfail = in_compliance(standardPF, ozonePF, no2PF, so2PF);
	so2_passfail = in_compliance(standardPF, ozonePF, no2PF, so2PF);
	
	//Repeat for so2, no2
	if(ozone_passfail == true)
		cout << "ground ozone (ppm)" << ozoneStats << "in compliance" << endl;
	else
		cout << "ground ozone (ppm)" << ozoneStats << "out of compliance" << endl;
	
	if(no2_passfail == true)
		cout << "nitrogen dioxide (ppm)" << ozoneStats << "in compliance" << endl;
	else
		cout << "nitrogen dioxide (ppm)" << ozoneStats << "out of compliance" << endl;

	if(so2_passfail == true)
		cout << "sulfur dioxide (ppm)" << ozoneStats << "in compliance" << endl;
	else
		cout << "sulfur dioxide (ppm)" << ozoneStats << "out of compliance" << endl;
	
	
		
		//Output location has some rating
		theRating = rating(ozone_passfail, no2_passfail, so2_passfail);
	cout << "Rating of " << location << "is" << theRating << endl;



	return 0;
}

string rating(bool ozone, bool no2, bool so2)
{
	string result;
	int count;
	
	count = 0;
	
	if(ozone == true)
		count++;
	if(no2 == true)
		count++;
	if(so2 == true)
		count++;
	if(count == 3)
		result = "Gold Star";
	if(count == 2)
		result = "Silver Star";
	if(count == 1)
		result = "Ok";
	if(count == 0)
		result = "Failing";
	
	return result;

}

bool in_compliance(float standard, float first, float second, float third)
{
	int count;
	count = 0;
	if(first <= 0 || second <= 0 || third <=0)
		return false; 


	if(standard >= first)
		count++;
	if(standard >= second)
		count++;
	if(standard >= third)
		count++;
	if(count >= 2)
		return true;
	else
		return false;
}

Where exactly does it not work? Also, I do not see casting anywhere, or where you are getting your floats for that matter; are you converting your strings to floats? I would use the <sstream> class to extract floats personally but frankly I'm a bit befundled by your code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.