473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

hi,i need to create a program that reads grades from external file and calculte the a

2
#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
int average(){
if(str[a]=="A")
{
score = 4.00;
}
if(str[a]=="A-")
{
score=3.67;

}
if(str[a]=="B+")
{
score=3.33;
}
if(str[a]=="B")
{
score=3.00;
}
if(str[a]=="B-")
{
score=2.67;
}
if(str[a]=="C+")
{
score=2.33;
}
if(str[a]=="C")
{
score=2.00;
}
if(str[a]=="C-")
{
score=1.67;
}
if(str[a]=="D+")
{
score=1.33;
}
if(str[a]=="D")
{
score=1.00;
}
if(str[a]=="D-")
{
score=0.67;
}
if(str[a]=="F")
{
score=0.00;
}











}
int main()

{
int sem[60];
string name[60]="";
int unit[60];
string str[60];
int a=0;
int number;
string matric;
float score;

ifstream inputFile;
ofstream tnputFile;
inputFile.open("result.txt");

if(!inputFile)
{
cout<<"Error opening file"<<endl;
system("pause");
return 1;
}

while(!inputFile.eof() && a<60)
{


inputFile>>sem[a]>>name[a]>>unit[a]>>str[a];

a++;

}
inputFile.close();
number=a;

for(a=0;a<number;a++)
{


cout<<sem[a]<<"\t"<<name[a]<<"\t"<<unit[a]<<"\t"<<str[a]<<endl;

}




return 0;
}
Dec 4 '18 #1
0 1030

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Kathy Benson | last post by:
Hi, I need to open an external file, such as *.htm from a Java program. I need to open this file by the default program that handles this extension on the machine. So *.htm should always be opened...
2
by: Hugh Macdonald | last post by:
I'm writing a tool at the moment that reads in an external file (which can use any Python syntax) At the moment, I'm reading the file in using: scriptLines = open(baseRippleScript).read()...
1
by: john | last post by:
I'm trying to develop fast, simple, html-based front ends for some Windows application programs. My idea: 1. Use html forms to let users supply run parameters (title, run options, etc.) 2. ...
2
by: teddarr | last post by:
I'm having trouble reading the first 2 lines of data in an external file. I am supposed to use a while loop to read the first 2 lines of an external file that contains several random integers. I...
5
by: johanneskrueger | last post by:
Hello, I'm currently using <xsl:copy-of select="document(...)/svg:svg"/to embed an SVG file into an XHTML file. I already defined the SVG namespace and assigned svg as its prefix in my XSLT 1.0...
2
by: CuteBeginner | last post by:
I need to write a program that reads a text file, which contains words that are followed with a preposition. If the preposition is wrong for the word, the program is supposed to warn the reader and...
9
by: John | last post by:
I need a scroller (java) or whatever that can read a php file and display it in the script. Does anyone know of any? I have searched the script sites but didn't find anything.
2
by: UofFprogrammer | last post by:
Hello, Several Weeks ago I asked a question about testing for the end of an input file. I have been using this method pretty well for inputting information from an external file. I am using C++. ...
2
aquagirl20
by: aquagirl20 | last post by:
I'm new in using tables. I have a series of getter methods and I wants to display them in a table. I've been trying to use the external file that my program saves but I'm having a hard time how to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.