zandiago 115 Nearly a Posting Maven Featured Poster

Thx to all for their input, program works perfectly.

zandiago 115 Nearly a Posting Maven Featured Poster

To get the largest and mimimum #, we could create/use a Max() function after we've declared/initialized i & count to zero:

int Max()
{
int largest = Numbers[0];
for(int i = 0; i < count; i++)
if( largest < Numbers[i] )
largest = Numbers[i];
return largest;
}

This is comparing through an array, but you could also other 'FOR' loops to accomplish what you want.

zandiago 115 Nearly a Posting Maven Featured Poster

Ok....i changed to this:

#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;

int main()
{
ifstream infile;
ofstream outfile;

infile.open ("gradesA.txt");
outfile.open ("gradeOutput");

int grades;//each individual grades
int testScoreAverage;//average of all grades
int testscores=0;//number of test scores
int totalgrade=0;
int max = -32767;//highest grade
int min = 32767;//lowest grade
int count = 0;
int i;

cout<<"Grades" <<"     Status"<<endl;
while(infile>>grades)
{	
	testscores=++testscores;
	totalgrade=totalgrade + grades;
	testScoreAverage =(totalgrade /testscores);
	cout<<grades<<endl;
	
  if 
	  (grades < testScoreAverage) 
  {
     
     cout <<setw(15)<<"Below"<<endl;
  }
  if (grades > testScoreAverage) 
  {
     cout  <<setw(15)<<"Above"<<endl;
  }
} 
      cout <<"AND THE MAX IS:  " << max << endl;
      cout <<"AND THE MIN IS:  " << min << endl;
	  cout<<"The # of test scores in the file: "<<testscores<<endl;
	  cout<<"The average grade was: "<<testScoreAverage<<endl;

	  infile.close();
      outfile.close();
	return 0;
}

My infile:

66
56
88
98
43

it does calculate the # of grades correctly...So pretty much, apart from the min and max everything else works. Except that the programs shows that i have 5 numbers in the infile(which is correct), however, on the screen it only prints out 4 lines of numbers...any idea why? Thx for your input.

I did a bit of messing around, but then it affects the average.
The output:

Grades     Status
66
56
          Below
88
          Above
98
          Above
43
          Below
AND THE MAX IS:  -32767
AND THE MIN IS:  32767
The # of test scores in the file: 5
The average grade was: 70

so the 1st # is missing a status.

zandiago 115 Nearly a Posting Maven Featured Poster

From the caribbean...luving my sunshine

zandiago 115 Nearly a Posting Maven Featured Poster

Ok guys, i did a bit of modification, much to simpler(to me that is)

#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;

int main()
{
ifstream infile;
ofstream outfile;

infile.open ("gradesA.txt");
outfile.open ("gradeOutput");

int grades;//each individual grades
int testScoreAverage;//average of all grades
int testscores=0;//number of test scores
int totalgrade=0;
int max = -32767;//highest grade
int min = 32767;//lowest grade
int count = 0;
int i;

while(infile>>grades)
{	
	testscores=testscores++;
	totalgrade=totalgrade + grades;
	testScoreAverage =(totalgrade /testscores);

  if 
	  (grades< testScoreAverage) 
  {
     cout << grades << " Below" << endl;
  }
  if (grades > testScoreAverage) 
  {
     cout << grades << " Above" << endl;
  }
	  for (i=0;i<count;i++)
	  {
		  if (grades[count]>max)
			 max=grades[count];
		  if (grades[count]<min)
			  min=grades[count];
	  }//end for i
}
      cout << "AND THE MAX IS:  " << max << endl;
      cout << "AND THE MIN IS:  " << min << endl;
	  cout<<"The # of test scores in the file: "<<testscores<<endl;

	  infile.close();
      outfile.close();
	return 0;
}

The error message that i get is:

error C2109: subscript requires array or pointer type

Based on what i have above, i should have been able to tell how much grades there are, there average, the highest, the lowest and eventually, whether each grade is below or above the average. Thx much for the input.

zandiago 115 Nearly a Posting Maven Featured Poster

Not everything on the internet is true!!!

zandiago 115 Nearly a Posting Maven Featured Poster

Thanks to all for the help. Problem solved.

zandiago 115 Nearly a Posting Maven Featured Poster

Oh boy....so whats gonna happen to the forum...

zandiago 115 Nearly a Posting Maven Featured Poster

Welcome!

zandiago 115 Nearly a Posting Maven Featured Poster

Welcome!

zandiago 115 Nearly a Posting Maven Featured Poster

Good day...welcome aboard.

zandiago 115 Nearly a Posting Maven Featured Poster
#include <iomanip>
#include <cmath>
#include <fstream>
#include <vector>
#include<string>
#include<sstream>
#include<iostream>

using namespace std;
int main()
{

	ifstream infile;
    ofstream outfile;

    infile.open ("paydata3.txt");
    outfile.open ("payOutput");

	string input, tmp;
	double totalemp=0;
	double totalgross=0;
	double totalfed=0;
	double totalfica=0;
	double totalhours=0;
	double totalover=0;
	double grossPay = 0;
		
	outfile<<"Emp. #"<<setw(14)<<"First Name"<<setw(12)<<"Last Name"<<setw(6)<<"Hours"<<setw(8)<<"Rate"<<setw(12)<<"Overtime"<<setw(8)<<"Gross"<<setw(12)<<"Fed Tax"<<setw(10)<<"FICA"<<setw(12)<<"City Tax"<<setw(14)<<"Union Dues"<<setw(16)<<"Net Pay"<<endl;
	while (getline(infile,input))
	{  
		
    
    //  declare variables to hold the values from the inputted line; not all have been used.
    string fname, lname, emplnum;
    char cityOrSuburb, unionOrNot;
    float hoursWorked, payRate, overtime, gross, fedtax, fica, ctax, netpay, undues, deductions;
    int dependents;

	{
    
    
    stringstream inputstream;
    
    //  creat temporary string from the substring
    tmp=input.substr(0,14);
    
    //  assign string to the stringstream
    inputstream.str(tmp);
    
    //  use extraction operator to get formatted value from stringstream
    inputstream >> lname;
	    
    //  repeat for a few more of the entries
    tmp=input.substr(15,10);
    inputstream.str(tmp);
    inputstream >> fname;
	inputstream.clear();
    
    tmp=input.substr(25,1);
    inputstream.str(tmp);
    inputstream >> cityOrSuburb;
	inputstream.clear();
    
    tmp=input.substr(26,1);
    inputstream.str(tmp);
    inputstream >> unionOrNot;
	inputstream.clear();

	tmp=input.substr(27,5);
	inputstream.str(tmp);
	inputstream >> emplnum;
	inputstream.clear();

	tmp=input.substr(32,4);
	inputstream.str(tmp);
	inputstream >> hoursWorked;
	inputstream.clear();
	
		
	tmp=input.substr(36,5);
	inputstream.str(tmp);
	inputstream >> payRate;
	inputstream.clear();
	
	tmp=input.substr(41,2);
	inputstream.str(tmp);
	inputstream >> overtime;
	inputstream.clear();
	
	
	tmp=input.substr(43,4);
	inputstream.str(tmp);
	inputstream >> dependents;
	inputstream.clear();

	{
		gross = (hoursWorked * payRate) + (1.5*payRate*overtime);
		gross += totalgross;
	}
{
	fedtax = ((gross - (dependents*17.0))*.1834);
	{
	fica = (gross * .0765);
	
}

if (cityOrSuburb == 'S')
{
ctax = 0.00;
}
else if (cityOrSuburb == 'C')
{
ctax = (gross * 0.04);
}

if (unionOrNot == 'X')
{ 
undues = 0.00;
} 
else if ( unionOrNot == 'M')
{
undues = (gross * .0473);
}

deductions = …
zandiago 115 Nearly a Posting Maven Featured Poster

Thx for my reply, however, i've moved those headers out and it still won't work, still says the values are zero. Let me repost my new code. Thx again AD!!

zandiago 115 Nearly a Posting Maven Featured Poster
#include <iomanip>
#include <cmath>
#include <fstream>
#include <vector>
#include<string>
#include<sstream>
#include<iostream>

using namespace std;
int main()
{

	ifstream infile;
    ofstream outfile;

    infile.open ("paydata3.txt");
    outfile.open ("payOutput");

	string input, tmp;
	double totalemp=0;
	double totalgross=0;
	double totalfed=0;
	double totalfica=0;
	double totalhours=0;
	double totalover=0;
		
	outfile<<"Number of employees processed ="<<setw(10)<<totalemp<<endl;
	outfile<<"Total Gross Pay ="<<setw(10)<<totalgross<<endl;
	outfile<<"Total Federal Tax ="<<setw(10)<<totalfed<<endl;
	outfile<<"Total FICA ="<<setw(10)<<totalfica<<endl;
	outfile<<"Total Hours Worked ="<<setw(10)<<totalhours<<endl;
	outfile<<"Total Overtime Hours Worked ="<<setw(10)<<totalover<<endl;
	outfile<<"Emp. #"<<setw(14)<<"First Name"<<setw(12)<<"Last Name"<<setw(6)<<"Hours"<<setw(8)<<"Rate"<<setw(12)<<"Overtime"<<setw(8)<<"Gross"<<setw(12)<<"Fed Tax"<<setw(10)<<"FICA"<<setw(12)<<"City Tax"<<setw(14)<<"Union Dues"<<setw(16)<<"Net Pay"<<endl;
	while (getline(infile,input))
	{  
		
    
    //  declare variables to hold the values from the inputted line; not all have been used.
    string fname, lname, emplnum;
    char cityOrSuburb, unionOrNot;
    float hoursWorked, payRate, overtime, gross, fedtax, fica, ctax, netpay, undues, deductions;
    int dependents;

	{
    
    
    stringstream inputstream;
    
    //  creat temporary string from the substring
    tmp=input.substr(0,14);
    
    //  assign string to the stringstream
    inputstream.str(tmp);
    
    //  use extraction operator to get formatted value from stringstream
    inputstream >> lname;
	    
    //  repeat for a few more of the entries
    tmp=input.substr(15,10);
    inputstream.str(tmp);
    inputstream >> fname;
	inputstream.clear();
    
    tmp=input.substr(25,1);
    inputstream.str(tmp);
    inputstream >> cityOrSuburb;
	inputstream.clear();
    
    tmp=input.substr(26,1);
    inputstream.str(tmp);
    inputstream >> unionOrNot;
	inputstream.clear();

	tmp=input.substr(27,5);
	inputstream.str(tmp);
	inputstream >> emplnum;
	inputstream.clear();

	tmp=input.substr(32,4);
	inputstream.str(tmp);
	inputstream >> hoursWorked;
	inputstream.clear();
		
	tmp=input.substr(36,5);
	inputstream.str(tmp);
	inputstream >> payRate;
	inputstream.clear();
	
	tmp=input.substr(41,2);
	inputstream.str(tmp);
	inputstream >> overtime;
	inputstream.clear();
	
	tmp=input.substr(43,4);
	inputstream.str(tmp);
	inputstream >> dependents;
	inputstream.clear();

	{
		gross = (hoursWorked * payRate) + (1.5*payRate*overtime);
		totalgross += gross;
	}
{
	fedtax = ((gross - (dependents*17.0))*.1834);
	
{
	fica = (gross * .0765);
	
}

if (cityOrSuburb == 'S')
{
ctax = 0.00;
}
else if (cityOrSuburb == 'C')
{
ctax = (gross * 0.04);
}

if (unionOrNot == …
zandiago 115 Nearly a Posting Maven Featured Poster

It still shows the total as being '0', in the totals section. I know the infile is ok, because everything except for the totals. Let me re-post my code. Thx for the assistance.

zandiago 115 Nearly a Posting Maven Featured Poster

Thanks for spotting the calcualtions part:

gross = (hoursWorked * payRate) + (1.5*payRate*overtime);
		totalgross += gross;

That doesn't work either...and i guess that after iget this part sorted out, that it will be the format for the other totals that i need. Thx for the assistance.

zandiago 115 Nearly a Posting Maven Featured Poster
grossPay = ???
totalgross += grossPay;

Well, i was using totalgross as the gross for all of the employees, but you used grossPay. So i guess you were trying to say:

grossPay=;
totalgross += grossPay;

It doesn't work, do you thinks it could also be because of variables outside of my while loop?

zandiago 115 Nearly a Posting Maven Featured Poster

Thx, Salem, that's what i had originally thought, but doesn't that increments the value by 1?

zandiago 115 Nearly a Posting Maven Featured Poster

I thought i did by the use of:

totalfica=totalfica++;
totalfed=totalfed++;
totalgross=totalgross++;
totalemp=totalemp++;

or would it be:

totalemp++;(instead of counter++)
totalemp+=

....and that would go inside the while loop?

zandiago 115 Nearly a Posting Maven Featured Poster

Write a c++ program that will read in an unknown number of employee records from a text file call “PAYDATA3.TXT”. Each employees record is a string of 47 characters (with spaces), set up as follows:

Positions Data Description
0 – 14 Last Name (15 characters)
15 -24 First name (10 characters)
25 Contains C if employee works in City office, otherwise S for Suburb
26 Contains M if employee is a union member, X if not a union member
27 – 31 Employee Number (5 digit characters)
32 – 35 Hours Worked (4 characters, in tenths)
36 – 40 Hourly Rate of Pay (5 characters)
41-42 Number of Dependents (2 characters)
43 – 46 Overtime hours worked (4 characters, in tenths, if any)

The program must perform the following tasks:
A. For each employee, calculate the gross pay
Gross = hours worked times hourly rate plus overtime hours time hourly rate times 1 ½
B. For each employee calculate the net pay as follows:
a. net pay = gross minus deductions
b. deductions are calculated as follows:
Federal Tax = (gross minus 17 times no. of dependents) times 18.34%
FICA = gross times 7.65%
City Tax = $0.00 if employee works in the suburbs
4% of gross if employee works in the City
Union Dues = $0.00 if employee is not a union member
4.73% of gross if …

zandiago 115 Nearly a Posting Maven Featured Poster

Any assistance is appreciated.

zandiago 115 Nearly a Posting Maven Featured Poster

Hello there, if you notice that your PC is running slow, it maybe possible that computer is still infected. In addition to viruses, your computer may be infected with spywares, Trojans, worms, adwares, viruses and other malwares. Personally, if a PC is infected, I do recommend using more than one antiviris program to help you. My personal recommendation for cleanup softwares are : Adware SE, ACE, Avast, AVG, Mcafee, ParetoLogic XoftSpySE, PREVX and spyware be-gone. Also, I do recommend that you clean/restore your registry files…if these are corrupted, your PC will slow down. The software to help you with your registry: RegCure and Regpair. Some of the above mentioned programs can be downloaded at www.cnet.com. Please use these utilities and let’s know the outcome. The removal of viruses and other malwares does affect your PC registry. Do the following to post a hi-jack log which we'll address for you, you must first download the software from:http://www.download.com/HijackThis/3...-10379544.html ==download hijackthis: http://www.majorgeeks.com/download5554.html
-install it to a new folder alongside your program files and then... rename hijackthis .exe to imabunny.exe
-in that folder start HijackThis by dclicking the .exe; now close ALL other applications and any open windows including the explorer window containing HijackThis.
-click the Scan and Save a Logfile button.
Post the log here so that we can take a look at it. Have a good day. Just a note also, that some viruses also pretend to be anti-viruses....so be careful of …

zandiago 115 Nearly a Posting Maven Featured Poster

Strayed off topic about the olympics but....The end of the world...2012? Maybe before that, as a possible new-cold war may emerge...

zandiago 115 Nearly a Posting Maven Featured Poster

A few things: What brand computer do you have? So after you boot the computer up....and all the lights come on ect...the screen stays black, or does it show thats it's going to startup up and then freeze? Have you tried booting from a CD/recovery disk instead of from the hard-drive? Cheer up, we'll help you out...

zandiago 115 Nearly a Posting Maven Featured Poster

Hello there, if you notice that your PC is running slow, it maybe possible that computer is still infected. In addition to viruses, your computer may be infected with spywares, Trojans, worms, adwares, viruses and other malwares. . My personal recommendation for cleanup softwares are : Adware SE, ACE, Avast, AVG, Mcafee, ParetoLogic XoftSpySE, PREVX and spyware be-gone. Also, I do recommend that you clean/restore your registry files…if these are corrupted, your PC will slow down. The software to help you with your registry: RegCure and Regpair. Some of the above mentioned programs can be downloaded at www.cnet.com. Please use these utilities and let’s know the outcome. The removal of viruses and other malwares does affect your PC registry. Also, there are softwares out there such as “Explorer Repair” that resets your TCP/IP settings, deletes ARP Cache, repair your host files, checks your winsock files . Hopefully, one of the guys will be able to address your log file and get back to you. You could also try uninstalling and re-installing internet explorer. Please download FixWareout from this site:
http://www.bleepingcomputer.com/file...Fixwareout.exe and then re-post your hijack log.
Please scan using the following website: http://www.pcflank.com/test.htm
After scan, it will let you know to some extent what area of your computer you need to check. (Ensure that your fire-wall is enabled)…. Also try http://www.kaspersky.com/virusscanner , let is scan your computer. Please also try: IEFix -- http://windowsxp.mvps.org/IEFIX.htm.

zandiago 115 Nearly a Posting Maven Featured Poster

Ok kool, thanks for pointing that out, never thought about that. Im going to make a bit of modifications to my source code for this assignment and re-post so you can see what's going on. Thx again.

zandiago 115 Nearly a Posting Maven Featured Poster

in addition to my questions above...our professor gave an example where he said that he created a program for a school and he created an array for 3000 (for the # of students), but actually there were 3002 students and he said that the school lost the data...or something to that effect....is that how sensetive the arrays allocation of memory/size is and why?

zandiago 115 Nearly a Posting Maven Featured Poster

ok i guess i'll stay with the vector although our professor will test the code with 60 records, so i guess an array to hold 60...

zandiago 115 Nearly a Posting Maven Featured Poster

Is there anyway i could bypass the vector?

zandiago 115 Nearly a Posting Maven Featured Poster

Thanks for catching that extra brace.

#include <iomanip>
#include <cmath>
#include <fstream>
#include <vector>
#include<string>
#include<iostream>

using namespace std;

int main()
{

ifstream infile;
ofstream outfile;

infile.open ("gradesA.txt");
outfile.open ("gradeOutput");

int grades;
vector <int> testScores;
while ( infile>> grades )
testScores.push_back ( grades );

int testScoresSize = testScores.size();
int sumofScores = 0;
double totalScores = testScores.size();
int min=0;
for (int i = 0; i < totalScores; i++)
{
		int max = 0;
        min = testScores.at(1);  
    for ( int i = 0; i < int (testScores.size()); i++ )
    {
        for ( int n = 0; n < int (testScores.size()); n++ )
        {
            int ival = testScores.at(i),   
                nval = testScores.at(n);  
            if (ival >= nval && ival >= max)
            {
                max = testScores.at(i); 
            }
            if (ival < nval && ival < min)
            {
                min = testScores.at(i); 

            }
		}
       
    }
    cout << "AND THE MAX IS:  " << max << endl;
    cout << "AND THE MIN IS:  " << min << endl;
	{
  if 
	  (testscore < testScoreAverage) 
  {
     cout << testscore << " Below" << endl;
  }
  if (testscore > testScoreAverage) 
  {
     cout << testscore << " Above" << endl;
  }
	
}

    infile.close();
    outfile.close();
    return 0;
}

It says that 'testscore' & 'testScoreAverage' are undeclared identifiers.

zandiago 115 Nearly a Posting Maven Featured Poster

It's possible that he wants you to use global variables, but if that's the case I'd seriously consider getting a new teacher.

Silly things teachers make you do make/mandate in codes frustrates the heck out of everyone, it's such a turn-off for noobs like.

zandiago 115 Nearly a Posting Maven Featured Poster

some of the syntax that i get just don't make any sense, for example it will say that one of my statements are missing a ';', but it's actually there already.

zandiago 115 Nearly a Posting Maven Featured Poster
#include <iomanip>
#include <cmath>
#include <fstream>
#include <vector>
#include<string>
#include<iostream>

using namespace std;

int main()
{

ifstream infile;
ofstream outfile;

infile.open ("gradesA.txt");
outfile.open ("gradeOutput");

int grades;
while ( infile>> grades )
testScores.push_back ( grades );

int testScoresSize = testScores.size();
int sumofScores = 0;
double totalScores = testScores.size();
for (int i = 0; i < totalScores; i++)
{
        int max = 0;
        min = testScores.at(1);  
    for ( int i = 0; i < int (testScores.size()); i++ )
    {
        for ( int n = 0; n < int (testScores.size()); n++ )
        {
            int ival = testScores.at(i),   
                nval = testScores.at(n);  
            if (ival >= nval && ival >= max)
            {
                max = testScores.at(i); 
            }
            if (ival < nval && ival < min)
            {
                min = testScores.at(i); 

            }
        }
        }
    }
    cout << "AND THE MAX IS:  " << max << endl;
    cout << "AND THE MIN IS:  " << min << endl;

    for (int testscore in testScores) 
    {
  if 
      (testscore < testScoreAverage) 
  {
     cout << testscore << " Below" << endl;
  }
  if (testscore > testScoreAverage) 
  {
     cout << testscore << " Above" << endl;
  }
    }
    }

    infile.close();
    outfile.close();
    return 0;
}
zandiago 115 Nearly a Posting Maven Featured Poster

How could I alter it to accomplish what i want? If i just declare it as a regular 'int', i'll still have problems though.

zandiago 115 Nearly a Posting Maven Featured Poster

What does the following mean?:

error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::vector<_Ty>' (or there is no acceptable conversion)

That error is regarding my statement:

ifstream infile;
ofstream outfile;

infile.open ("gradesA.txt");
outfile.open ("gradeOutput");

vector <int> testScores;
while(infile >> testScores)
	{
	int grades;        
	infile >> grades;
	testScores.push_back(grades);
	}

Thanks for the input.

zandiago 115 Nearly a Posting Maven Featured Poster

Sorry to hear about the loss of your laptop. Pitty you didn't get the lo-jack with it. I remember reading somewhere that there is a software that if installed on the laptop (while in owners possession) would alert the owner if someone tries to access the interent. It would let them know that their IP address has been used. However, they could use softwares to perhaps alter the IP address, thus not allowing the owner to find it. Again, this is something that i read....not something I've verified. Well, you took a first right step in filing a police report. If you had personal/confidential data on your laptop, such as soc sec #, bank acct info, ect....then contact your bank and the credit bureas so that they can place an alert out there if anyone tries to use your data. Cheer up!

zandiago 115 Nearly a Posting Maven Featured Poster

It's best to look at the line you're told, and about five lines above it.

Good tip, thx for that one. The '{' for the main function totally slipped me...thx again.

zandiago 115 Nearly a Posting Maven Featured Poster

:( sorry for my laziness. With regards to the errors, im pretty sure that the 'infile' statement is correct. I think I have all the necessary header files. But it says that 'infile', 'ifstream' & 'cout' are: unknown override specifier or see declaration of 'outfile'. I've never had this problem before. The name of the infile is correct, but the funny thing is that the 'outfile' is created.

zandiago 115 Nearly a Posting Maven Featured Poster

Professors now-a-days.... there are basic syntax errors such as problem with my infile statement and the 'for' statement. any ideas why i'm having these problems.

zandiago 115 Nearly a Posting Maven Featured Poster

Thanks for your input, any reason why my ifstream shows an error. Also with regards to the infile.eof(), our professor said it was necessary for it to be there to read through the entire documents, even though i know that getline could do it. My professor tactually took off 10% of my assignment because i didn't use the while(!infile.eof()). It compiled fine without it and got the results just like anyone else. Any reason why he may harp on that so much? Beside there are otherways, to have the compiler show if their is an error if the infile isn't working. Thx to all for their input.

zandiago 115 Nearly a Posting Maven Featured Poster

I found an assignment that was pretty similar to mine, and did a bit of mofifications accordingly. I'm having errors with it. Their was a suggestion to use vectors in the program, we haven't reached vectors yet in our course, but below is the code along with the syntax error messages. Any additional info/pointers is greatly appreciated.

#include <iomanip>
#include <cmath>
#include <fstream>
#include <vector>
#include<string>
#include<iostream>


using namespace std;

int main()

ifstream infile;
ofstream outfile;

infile.open ("gradesA.txt");
outfile.open ("gradeOutput");



vector<int> testScores;    
while(!infile.eof())
    {
    int grades;        
    infile >> grades;
    testScores.push_back(grades);
    }

int testScoresSize = testScores.size();
int sumofScores = 0;
double totalScores = testScores.size();
for (int i = 0; i < totalScores; i++)
{
        int max = 0;
        min = testScores.at(1);  
    for ( int i = 0; i < int (testScores.size()); i++ )
    {
        for ( int n = 0; n < int (testScores.size()); n++ )
        {
            int ival = testScores.at(i),   
                nval = testScores.at(n);  
            if (ival >= nval && ival >= max)
            {
                max = testScores.at(i); 
            }
            if (ival < nval && ival < min)
            {
                min = testScores.at(i); 

            }
        }
    }
    cout << "AND THE MAX IS:  " << max << endl;
    cout << "AND THE MIN IS:  " << min << endl;

    for each (int testscore in testScores) 
    {
  if 
      (testscore < testScoreAverage) 
  {
     cout << testscore << " Below" << endl;
  }
  if (testscore > testScoreAverage) 
  {
     cout << testscore << " Above" << endl;
  if (testscore == testScoreAverage) 
  {
     cout << testscore << " Average" << …
zandiago 115 Nearly a Posting Maven Featured Poster
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>


using namespace std;

int readInfo(); 

int main()
{
  int returnVal;
  returnVal = readInfo();
  return returnVal;
}

int readInfo()
{
    ifstream infile;
    ofstream outfile;

    int num = 0;//number of grades
    int Hi =0;//highest test grade
    int Low=0;//lowest test grade
    string stat;//status of grade, whether higher or lower than average

    infile.open ("gradesA.txt");
    outfile.open ("gradeOutput2");
    double number = 0;
    double average;

    int count = 0;
    int storedGrades[60];
    while (!infile.eof())
    {    
		storedGrades[count] = number;    
		++count;
	}    
	{
        average = (number/num);//average of all the grades
		cout<<number<<endl<<endl;
        if (number<average)
        {
        cout<<number<<setw(5)<<" Below"<<endl;
        }
        else if (number>average)
        {
        cout<<number<<setw(5)<<" Above"<<endl;
        }
        //increment for number of grades?
		num++;
	}
        
        cout<<"The number of test scores : "<<num<<endl;
        cout<<"The average of the test scores : "<<average<<endl;
        cout<<"The highest test score was "<<Hi<<" and the lowest test grade was "<<Low<<endl;
        cout<<"Grade "<<setw(5)<<"Status"<<endl;
       
    infile.close();
    outfile.close();
    return 0;
}

Good day. I know the code isn't complete, but any reason why nothing isn't being printed on the screeen even though it compiles ok? Thx.

zandiago 115 Nearly a Posting Maven Featured Poster

what "problem" does it say it's having? Copy the error log and post it here so that we can see it.

zandiago 115 Nearly a Posting Maven Featured Poster

Try this:

srand ( static_cast<unsigned int> ( time ( 0 ) ) );

  int randNum = rand() % 10 + 1;

:cool:

zandiago 115 Nearly a Posting Maven Featured Poster

Ok lerner, thx much for your input. i'll repost my code with the modifcations.

zandiago 115 Nearly a Posting Maven Featured Poster

darsh999..u can make games using c++ which require user input.

zandiago 115 Nearly a Posting Maven Featured Poster

Oh goodness, old age setting in one me...i read through the assignment question 2 qucikly...

zandiago 115 Nearly a Posting Maven Featured Poster

i did this program with the loops and not needing a separate functions from main.

zandiago 115 Nearly a Posting Maven Featured Poster

well, if you change the 'int' to another number characteristic, you'll bypass some of the restrictions. What restrictions are you trying to bypass or implement?

zandiago 115 Nearly a Posting Maven Featured Poster

Take a brief look at this:

#include <iomanip>
#include <cmath>
#include <fstream>
#include <string>
#include<string>
#include<iostream>

using namespace std;


int main()
{

	int num1 = 0;
	int num2 = 0;

	cout<<"Please enter two numbers to get their total"<<endl;
	cin>>num1>>num2;

	double sum = (num1 + num2);
	cout<<sum<<endl;
	return 0;
}

Also, when you're posting your code, please place them in code & # number tags as it makes it easier to read for those helping.