Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 109,548 C++ Programmers for FREE! Ask your question and get quick answers from experts. There are 1,225 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



how to count the integers from a file

 
Reply to this topicStart new topic

how to count the integers from a file

werox51
post 7 Aug, 2008 - 06:48 PM
Post #1


New D.I.C Head

*
Joined: 6 Aug, 2008
Posts: 4

CODE

#include <iostream>            
#include <iomanip>        
#include <fstream>
#include <cmath>
using namespace std;
int let2num();
int main ()
{
float GPA, grades, classes;
int letters;
ifstream inFile;
ofstream outFile;
inFile.open ("indata2.txt");
if (!"indata2.txt")
{
    cout << "Input file not found."<<endl;
    return 0;

}

outFile.open ("outdata2.txt");
if (!"outdata2.txt")
{
    
    cout << "output file not found."<<endl;
    return 0;

}
let2num(letters);
if (letters>=1)
{
    GPA = letters/classes;

}
else (letters<=0)
{
    cout<<letters<<"This grade will not be counted for the GPA."<<endl;
}

return 0;
}
  




hi guys im doing program to calculate the GPA but i need to extract the grades from a file and show the number of grades my doubt was how do i read the letters from a file and assign them numbers and how do i count them sorry if i have gramatical errors but irecently move to the us thank u! XD
User is offlineProfile CardPM

Go to the top of the page


no2pencil
post 7 Aug, 2008 - 07:12 PM
Post #2


Wet D.I.C.

Group Icon
Joined: 10 May, 2007
Posts: 4,947



Thanked 27 times

Dream Kudos: 2325

Expert In: Goofing Off

My Contributions


Create a counter.

cpp

int count=0;


& then increase it every time that a grade is entered.

cpp

if (letters>=1)
{
GPA = letters/classes;
count++;
}
else (letters<=0)
{
cout<<letters<<"This grade will not be counted for the GPA."<<endl;
}
User is online!Profile CardPM

Go to the top of the page

werox51
post 7 Aug, 2008 - 09:44 PM
Post #3


New D.I.C Head

*
Joined: 6 Aug, 2008
Posts: 4

thanks XD
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 9/7/08 10:28PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month