C/C++ :: Program To Compute Students Grades From File And Write Them To File?

Aug 31, 2014

We have to write a program that reads an input file containing data in the form:

Martha J, 80, 90, 90, 100, 89, 99, 85
Anna Smith, 65, 72, 77, 68, 62, 70, 65
Bill Gates, 60, 54, 89, 62, 65, 60, 50
...etc...

and then use that information to determine their letter grade and write that information to a .txt file. I have been able to successfully pass that information to a function to determine their letter grade and have been able to successfully compute their letter grade. However, I can get this information to successfully post within the *computeGrade () function. Yet, I don't know how to pass this information back to the main() on a student by student basis so that I can open a new .txt file and write just their name and letter grade to it.

Another issue I'm having is when it comes to computing the averages of the class. Each score is either a quiz (there are 4), a midterm (there are 2) or a final (there is 1). I'm a little stuck on how to pass say all of the quiz 1 grades as one entity to the function averagesminmax(). Is there a way to compile each of the grades for a specific quiz or midterm as one array and pass that to the function to then do the computation. Also we need the min and max so again from compiling the grades of a particular quiz or exam together as one.

Here's the code that I have so far.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
const char *computeGrade();
int averagesminmax();
int main() {
char fName[20];
char lName[20];

[code]....

Do I need to re-read the input file and assign them to different variables?

Here's a sample of the output so far:

Enter input .txt file name
Graded
Thui Bhu, 91, A
Ariana B. Smith, 96, A
Emily Gonzales, 83, B
Jennifer L, 89, B
Maria Jones, 67, D
Bill Gates, 55, F
Escobar Morris, 78, C
Anne Latner, 88, B
Program ended with exit code: 0

Also in my output file, the only thing that it prints will be the first name of whatever the last student in the input file list is.

View 2 Replies


ADVERTISEMENT

C :: Program To Calculate Students Grades From Input File And Write To Output File

Aug 29, 2014

One of my class assignments is to create a program that receive a .txt file containing a students name and their grades as follows:

John K. 99, 87, 57, 89, 90, 95
Amanda B. Jones 100, 88, 76, 99, 86, 92
etc..

The number of students is unknown until run time. You have to take those grades and average them weighing the first (4) at 10% a piece and the last (2) at 30% each.

Then return an output file with the students name and their letter grade A,B,C,D,F based on their computed score. In addition, on screen it needs to display the average scores for each Q1, Q2, etc. as well as the minimum and maximum for each test on the screen. I am having a hard time in assigning the scores to a variable so that they can then be computed as an average and then used to determine a letter grade. I have begun to write the code and am a bit stuck..here's what I have so far:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

[Code]....

View 2 Replies View Related

C/C++ :: Write Program That Calculate Students CGPA And Store In To File Name

Jan 16, 2015

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

[Code]...

View 2 Replies View Related

C++ :: Program That Compute Final Average Grades Of Class

Jan 28, 2013

An instructor needs you to write a program that will compute the final average grades in her class. There are 5 students in the class. Each student must take 2 exams and 4 quizzes as part of their final grade. The weight of each toward the final grade is as follows:

Exam 1 – 30%
Exam 2 – 30% Quiz 1 – 10%
Quiz 2 – 10%
Quiz 3 – 10%
Quiz 4 – 10%

You must use arrays to store each students 3 digit ID number, exam scores and quiz scores. A multi-dimensional array is mandatory. Request from the user the information needed then output all of the information as well as the final average grade for each student.

View 1 Replies View Related

C/C++ :: Write Random Grades To File?

Jul 1, 2014

I need to write a program to store a user specified number of grades to a file, with one grade per line. random function to generate grades between a 55 and 100. When you open the file, it should be for writing, and not appending. Again, prompt the user for how many grades to generate, and store them in a file.

View 2 Replies View Related

C++ :: Write Program That Uses Function To Compute The Cost?

Nov 1, 2013

Write a program that uses a function to compute the cost of a pizza with given diameter and the number of toppings. Constant will be the cost per toppings and cost per square inch. It will contain a reputable structure as well.

diameter=17
number of toppings=3

//complier directives
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>

[Code].....

View 6 Replies View Related

C++ :: Write Program That Asks User To Enter Student Grades?

Jan 21, 2014

Write a program that asks the user to enter a student’s grades on four exams. The program should display the four grades and the average of the four grades,rounded to the nearest tenth. To add the grades, use a variable called total_grade, which you should initialize to zero.As the program prompts for and obtains each grade, add the grade to total_grade using the += operator.

View 3 Replies View Related

C++ :: Write A Program To Store Marks Obtained By 50 Students?

Feb 28, 2014

Q.1 Write a program to store marks obtained by 50 students. Initialise the array having passed to a function initilise() having passed the array as parameter. Write another function which should take this array as parameter and return the highest score from the array. you have to write the proper function call, prototype and definition for each function.

And this is the program which i wrote and got errors: -

#include<iostream.h>
#include<conio.h>
#define s 50
void init(int m[s]);
void display(int m[s]);
void find_max(int max, int m[s]);
void main(){
clrscr();
int max;

[code]....

View 1 Replies View Related

C :: Program That Grades A True / False Quiz - Data Available In Text File

Oct 14, 2014

You are to write a C program that grades a true-false quiz. The quiz data will be available in a text file; here is an example:

Quiz #8 (09/22/14) (corrected version)
TTFTTFTFTF
0080 TTFTTFTFTF
0340 TTFTFFTFTF

The first line in the data file is a comment that you may assume can be up to 80 charac- ters long; it cannot be blank. The second line contains the answer key for the 10-question true-false quiz. The following lines in the data file contain a student's id number in column 1 followed by their answers for the quiz in column 2. A 0 (zero) on a line by itself indicates that there are no more students to process.

Write a program that first reads in (from standard input; more on this in a moment) the comment line and answer key as strings followed by each student's data. Store the student's id numbers in an array. You are to "grade" each student's quiz using the key provided fol- lowed by recording their scores (in a second array) in order to be able to print them out later. You do not need to use an array of strings or characters in your program. Write your program allowing for up to 100 students, and you may assume that at least 1 student will have taken the quiz.

You should create test data text files and provide the data to your program using redirection from the command line (see the sample run below). Your program should output the number of students who took the quiz, the average score, the best score, and a table showing each student's id, score, and grade. The formatting, spacing, and labels in your output should 1 match the sample run below exactly.

Your program should determine each student's grade as follows: if the score is equal to the best score b or b−1, give an A. If it is b−2, award a B. Give C's for any score that is equal to b−3 or b−4, a D for b−5 and an F for all others.

Alright So I'm just stuck at comparing the key answer with student answer here is my code comparing one student's answer with the answer key . is that right ?? One more thing for some reason when i try to print answer[0] the result is nothing why is that

Code:
#include<stdio.h>
int main(void) {
char comment[80];
char answer [10];
char studentans [10];
int n=0,i=0,x=0;
int ID[10];

[Code] .....

View 1 Replies View Related

C :: Computing Grades From Input File And Writing To Output File

Aug 31, 2014

One of my class assignments is to create a program that receive a .txt file containing a students name and their grades as follows: John K. 99, 87, 57, 89, 90, 95 Amanda B. Jones 100, 88, 76, 99, 86, 92 etc.. The number of students is unknown until run time. You have to take those grades and average them weighing the first (4) at 10% a piece and the next (2) at 15% each and the final at 30%. Then return an output file with the students name and their letter grade A,B,C,D,F based on their computed score. In addition, on screen it needs to display the average scores for each Q1, Q2, etc. as well as the minimum and maximum for each test on the screen. I am having a hard time in assigning the scores to a variable so that they can then be computed as an average and then used to determine a letter grade. I have begun to write the code and am a bit stuck..here's what I have so far:

Code:
//
// main.c
// Final Exam
//

[Code].....

The problem I'm having now is how to go about passing the grades to the function computeGrade and then compute the average and return that to the function.

View 4 Replies View Related

C++ :: Struct - Getting Grades Of The File Sorted

Jul 21, 2014

My code has no errors. I'm just having problems with getting the grades of the file sorted. grades is not a struct, but is a int inside struct School. Below is what I;m having problems with(this is just the code I started working with,I made a few changes but it didn't work,I have no clue)

void selectionSortG() {
Students min;
int key;
for (int i = 0; i < size; i++){
min = student[i];
key = i;
for (int k = i; k < size; k++)

[Code] ....

View 2 Replies View Related

C :: Write A Program To Copy One File To Another?

Feb 11, 2013

Here I was trying to write a program to copy one file to another.

Code:
#include <stdio.h>#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *fp , *ft;

[Code]....

So it should copy test1 to test2. Now I created test1 in gedit. I just put one character "c" in it and closed it. And I ran the program. When I check sizes of test1 and test2 , using

ls -l

command, I see that test2 has 4 bytes and test1 has 2 bytes. So something strange is happening here. I just put a single character in test1, so shouldn't it show 1 byte ? And why test2 is showing 4 bytes ? I have Win XP on my laptop. And I use Ubuntu 12 inside VirtualBox. So this is Linux environment...

View 10 Replies View Related

C++ :: Write A Program That Reads Data From A File?

Feb 26, 2013

Write a program that reads data from a file (use the attached data file). These data are a student name and 3 test scores. The program should calculate the average of the 3 test scores, and display the name, 3 test scores, and the average to the monitor.

Useful tips:
a) Include the following header files: iostream, fstream, iomanip, and string
b) The name of the data file is “datafile.txt”, you need to save the file in the same folder of the source file.
c) use the manipulators (setw, setprecision, setfill, showpoint, fixed) to format the average with 1 digits after decimal point as following.
d) Use character ‘ ’ for tab.

View 3 Replies View Related

C++ :: Program That Allow User To Read / Write Onto File

Jan 28, 2013

So I'm trying to create a program that allows one to read/write on to output.txt. I though I had everything set up right, but its only writing one word to the text file. Heres the code.

#include "stdafx.h"
#include <iostream> //Needed for User Input
#include <fstream> //needed for ofstream
#include <string> // needed for strings
#include <windows.h> //needed for Sleep
#include <cstdlib> //Needed for return EXIT_SUCCESS;

using namespace std;
int main() {
ofstream outputfile; //allows to read and write to files

[Code] .....

If I type Puppies Are Cute and go to output.txt, the only thing written in the text file is Puppies.

View 9 Replies View Related

C/C++ :: Write A Program Where It Asks The User For A File Name?

Apr 18, 2014

I'm trying to write a program where it asks the user for a file name.

If that file exists, the it will open the file and then read it and print the information in the file.

However, if the user enters a file name that does not exist, the user will have 2 more tries (for a total of 3 tries) to get the correct name of the file.

I am close to getting it. What I have now just won't go through the loop to validate if the input matches an existing file. It goes straight to the printing of what is in the file. If the file doesn't exist, it prints: "Found your file..Opening..processing...Total keys found = 0."

So, my question, what am I doing wrong that it won't go through the loop properly?

#include<iostream>
#include<iomanip>
#include<fstream>
#include<string>
using namespace std;
int main() {
bool fileFound = false;

[code]....

View 2 Replies View Related

C/C++ :: Display Average GPA Of Some Students In A File

Nov 29, 2014

I have learnt about string class, file I/O and pointers. Now I am asked to write a program that includes the above topics, basically testing the ability to use dynamic arrays.

I've got 2 documents, namely "Students.txt" and "EnrollRecords.txt". "Students.txt" includes 40 students' info, which are university ID, programme names and their names. These 40 students are all BEng but from different departments.

E.g. 20141129 BEng(Civil) Tom Jerry

"EnrollRecords.txt" includes 166 data, which are course codes, university ID, respective scores in the test and GPA. In this document, the same student can have several scores of different courses' tests. So their uids repeat in it. And this document only contains the data of the Department of Computer Science. So students exist in the "Students.txt" may not exist in this document.

So my task is that the user enter a name (e.g. John), then the programme will know to find John and his uid, and get all the GPA of the courses that he has taken to calculate the average GPA.

E.g. 20147777 BEng(CompSc) John David //this is a John we are looking for in the "Students.txt"

//line 15 COMP1220 20147777 90 4 //so we find 3 courses in "ErollRecords.txt" that John has taken
//line 50 COMP1500 20147777 85 3.3
//line 88 ENGG2012 2014777 70 2.3

The programme should display :

20147777 3.2

To able to do anything for this task, I am asked to define 4 struct types:

struct Student {
int uid;
string programme;
string name;

[Code] ....

So now I am going to write a function queryD(Database d, string searchName) and any necessary functions in it. I am able to do the search part,

void queryD(Database d, string searchName) {
for (int i = 0; i < d.numberOfStudents; i++) {
if (d.students[i].name.substr(0, searchName.length()) == searchName) {
match_uid(d);

[Code] ....

But I struggle in how to match the uid in "Students.txt" and "EnrollRecords.txt" . Because there are repeated data for the same student in "ErollRecords.txt". So how am I gonna be able to match the uid and do the calculation? I get stuck in the for loop part...

View 1 Replies View Related

C++ :: Write A Program That Will Read Names From Input File

Apr 24, 2014

I have a lab with the following instructions:

Manually create an input text file called Lab22BInput.txt with the following data:

Dove
Doe
Alston
Zebra
Egg

Write a program that will read the names from the input file. Print out each of the names read to the screen. The program should go through the list of names and determine which comes 1st in the alphabet. The program should determine how many letters are in this name. Print out the name that comes first in the alphabet and the length of the name.

I have created the input file, and the data correctly outputs to the screen when I run the program. However, I do not know what kind of logic to use to sort them alphabetically and determine the amounts of characters.

So far I have the following:

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string str1, str2, str3, str4, str5;

[Code]...

View 2 Replies View Related

C++ :: Write Program For Class That Reads From Input File?

Mar 7, 2013

I am trying to write a program for class that reads from an input file the month, year & total collected. I am using notepad for the input file.

This is what the notepad file looks like
-----------------------------------
March 2013 63924.62

Why does it give me random numbers in the output rather than what the notepad has?

Also, the outfile is completely blank.

#include <iostream>
#include <iomanip>
#include <fstream>

[Code].....

View 2 Replies View Related

C++ :: Program Which Takes Input From User And Write It To A File

Jan 15, 2013

A program which takes input from user and write it to a file then it reads data from that file then it should search for specific data such as email adresses or url etc.

View 1 Replies View Related

C++ :: How To Compute Financial Ratio With Using Header File

Aug 19, 2013

How to compute financial ratio in C++ with using header file?

Calculate in c++ program with 3 different file. - 2 file (cpp file) - 1 file (header file)

Information:

formula:-
*1.*Current ratio = (current asset / current liabilities)
*2.*Gross margin = (Revenue – Cost of goods sold) / Revenue
*3.*Operating margin= (Operating Income / Revenue)
*4.*Profit margin = (Net Profit / Revenue)
*5.*ROE= (Net Income/Shareholder's Equity)

I want put 5 formula to run the program. How to put 5 formula in the program but run one formula.

EXAMPLE: In the coding, write all financial ratio. When we compile, just asking 1 formula value only. We need to fixed, which formula to run. Just adjust the coding only.

View 7 Replies View Related

C++ :: Program To Merge Numbers In Two Files And Write Results To Third File

Apr 9, 2013

I need to write a program that merges the numbers in two files and writes the results to a third file. The program reads input from two different files and writes the output to a third file. Each input file contains a list of integers in ascending order. After the program is executed, the output file contains the numbers from the two input files in one longer list, also in ascending order. Your program should define a function with three arguments: one for each of the two input file streams and one for the output file stream. The input files should be named numbers1.txt and numbers2.txt, and the output file should be named output.txt.

View 1 Replies View Related

C/C++ :: Find Average Of 20 Students By Using A File And One Dimensional Array

Jan 22, 2015

is this according to it??

#include <iostream>
#include <fstream>
using namespace std;
int main(void){
fstream file("textfile.txt");
int linecount = 0;
int tempArray[100];

[Code] ....

View 1 Replies View Related

C/C++ :: Write A Program That Reads Four Float Numbers From The Input Text File

Apr 3, 2015

I need to write a program that reads four float numbers from the input.txt file, then it prints out the greatest of the four numbers into the output.txt file. I did everything, but the numbers don't print out.

#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream inFile;
ofstream outFile;
float number1, number2, number3, number4;

[Code]...

View 2 Replies View Related

C :: Creating Linked List Of Students With Individual Data Read From A File

Aug 27, 2014

In the program I'm writing, I'm creating a linked list of students with individual data read from a file. At the moment, I have written two functions to accomplish this; one that creates a student node and fills it from a line file, and a second that calls on the first to create a linked list. It seems to work fine except for one thing; It seems that EOF is being reached first, but the function continues on anyways? Here is my code so far...

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct student
// Declaring student structure globally.

[Code] .....

And here is what the input file would look like...

Thui Bhu, 100, 90, 80, 100, 89, 99, 88
Ariana B. Smith, 90, 90, 100, 100, 99, 100, 95
Emily Gonzales, 100, 90, 100, 70, 78, 78, 80
Jennifer L, 80, 90, 90, 100, 89, 99, 85
Maria Jones, 65, 72, 77, 68, 62, 70, 65
Bill Gates, 60, 54, 38, 62, 65, 60, 50
Escobar Morris, 83, 77, 88, 76, 79, 72, 76
Anne Latner, 80, 80, 85, 95, 90, 95, 98
John Doe, 45, 87, 88, 89, 67, 96, 79

And here is what the output is...

EOF

EOF in create_record

Thui Bhu: 100 90 80 100 89 99 88
Ariana B. Smith: 90 90 100 100 99 100 95
Emily Gonzales: 100 90 100 70 78 78 80
Jennifer L: 80 90 90 100 89 99 85
Maria Jones: 65 72 77 68 62 70 65
Bill Gates: 60 54 38 62 65 60 50
Escobar Morris: 83 77 88 76 79 72 76
Anne Latner: 80 80 85 95 90 95 98
John Doe: 45 87 88 89 67 96 79
Press any key to continue . . .

View 2 Replies View Related

C :: Create File To Write Text And Read Back The File Content

Mar 15, 2013

The Objective Of This Program Is To Create A File To Write Text And Read Back The File Content. To Do That I Have Made Two Function writeFile() To Write And readFile() To Read.The readFile() function works just fine but writeFile() doesn't.

How writeFile() function Works? when writeFile() function Execute It Takes Characters User Type And When Hit Enter(ASC|| 10) It Ask "More?(Y/N)" That Means What User Want? Want To Go Next Line Or End Input?

If "Y" Than Inputs Are Taken From Next Line Else Input Ends.

But The Problem Is When Program Encounters ch==10 It Shows "More?(Y/N)" And Takes Input In cmd variable.If cmd=='Y' I Mean More From Next Line Than It Should Execute Scanf Again To Take ch I Mean User Input.But Its Not!!! Its Always Showing "More?(Y/N)" Again And Again Like A Loop.

Code:
#include <stdio.h>
void writeFile(void);
void readFile(void);
int main(){

[Code].....

View 5 Replies View Related

C++ :: Decompress Input File And Write Results Into Output File?

Jul 8, 2013

how do i decompress an input file and write the results into an output file?

also my do while loop is supposed to keep going unless the user selects the option to exit the program, instead it exits after finishing ay of the options.

here's my code so far...

#include <iostream>
#include <iomanip>
#include <fstream>

[Code]....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved