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


ADVERTISEMENT

C++ :: How To Create True False And Multiple Choice Questions Using Text Files

Jan 7, 2015

So im trying to create a quiz using c++ that incorporates three different types of questions. These are the standard one answer question, true false questions and multiple choice questions.

How to create the true false and multiple choice questions?

One way that i came up with looks like this

Question A answer1 B answer2;

View 2 Replies View Related

C/C++ :: Quiz Program Based On Data File Handling

Dec 22, 2014

I'm trying to make a Quiz program based on C++'s Data File Handling capablities. I've attached the code in .txt file and I wonder why I'm getting the error identifier bScience cannot have a type qualifier?

Attached Files QuizPro.txt (9.6 KB)

View 7 Replies View Related

C++ :: True / False About Function Parameter

Sep 11, 2014

is it true or false

a function like void myfun(int num){} can receive type "int var" but can't receive type "const int var"

AND

a function like void myfun(const int num){} can receive both type "int var" and also type "const int var"

View 3 Replies View Related

C++ :: How To Switch Between Boolean True / False Logic Within Do / While Loop

Mar 25, 2014

I have a hit a snag in a number guessing game program. I was given a half-completed program and told to use functions to complete the missing pieces. It looks unwieldy, but this is how it is supposed to be. I have temporarily made the random guess value visible for troubleshooting purposes.

#include <iostream>
#include <time.h>
#include <stdlib.h>
using namespace std;
int welcome() {
cout << " Welcome to the hi-low game!" << endl;

[code]....

The issue lies within this piece of code:

checkGuess(guess, correct); done = false; //either true or false
} while (!done);
cout << "Congratulations, you got it!" << endl;
return 0;
}

I need to manipulate the Boolean variable done so that it registers as false when the user inputs a number higher or lower than the randomly selected value. However, if the user guesses correctly, done will become true and the program will end.

As it stands now, the program will not terminate, and if I set done equal to true like so:

checkGuess(guess, correct); done = true; //either true or false
} while (!done);
cout << "Congratulations, you got it!" << endl;
return 0;
}

Every number the user inputs will register as correct instead of the one right guess.

View 4 Replies View Related

C++ :: Palindrome That Takes A Vector Parameter And Returns True Or False

Apr 26, 2014

Write a function palindrome that takes a vector parameter and returns true or false according to whether the vector does or does not read the same forward as backward (e.g., a vector containing 1, 2, 3, 2, 1 is a palindrome, but a vector containing 1, 2, 3, 4 is not).

Code :
#include <vector>
#include <iostream>
using namespace std;
void palindrome(vector<int>);

[Code] .....

View 4 Replies View Related

C++ :: Binary Search Function - Return True If Element Inputted By User Found In Array And False If Not

Nov 9, 2014

I was instructed to write a binary search function which would return true if an element, inputted by the user, was found in the array, and false if it was not. I'm not sure why, but my function always returns false. My code is as follows.

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
//binary search function
bool search (int array[], int item)

[Code] ....

Why my code does not fulfill it's purpose???

View 7 Replies View Related

C++ :: Quiz Program - Checking Whether Entered Answer Is Correct From A File

Apr 15, 2014

My code is not moving past the line below...actually i am making a quiz and this piece of code id checking whether the entered answer is correct, from a file..

getline(anss,saveans);
while(a<1) {
getline(anss,saveans);
if (saveans == ToString(randNum)) {
getline(anss,saveans);
if (saveans == ans)

[Code] ....

View 9 Replies View Related

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++ :: 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 View Related

C++ :: Multiple Quiz Program - Adding High Score For Each User Stored In Binary File

Jul 11, 2014

I am making a multiple quiz program. So everything is working fine, except for the part where i'm trying to add a highscore for each user which is being stored in a binary file. I have added a sample of the program containing the error. This isn't the actual program, which is very long.

class user { //The collection of all info pertaining to the users
char user_id[50];
public:
int hscore1;
user() {
strcpy(user_id,"NULL");
hscore=0;

[Code] ....

View 1 Replies View Related

C :: Comparison Is Always False Due To Limited Data Type Error

Feb 16, 2013

Code:

do {
printf("Edit the entry's cellphone number:");
scanf("%s", addressbook[4][num]);
length = strlen(addressbook[4][num]); //gets the length of the input (should be 10)
//checks if the input is composed of 11 elements wherein the first 2 are 0 and 9 respectively
for(i=0; i<11; i++){

[Code] ....

why do I get an error here?

Code:
if ((addressbook[4][num][0] == '0') && (addressbook[4][num][1] == '9') || (addressbook[4][num][i]>='0') && (addressbook[4][num][i]<='9') && (length=='11'))

And how do I fix this?

The error message is: comparison is always false due to limited data type

View 1 Replies View Related

C :: Math Quiz Program - Multiplication Function

Nov 16, 2014

Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void correctResponse(void);
void incorrectResponse (void);
void multiplication( void ); // function prototype

[Code] ....

// end function multiplication

// It keeps crashing. How do I compile the responses into a grade?

View 5 Replies View Related

C++ :: Data Input Into A Text File While Not Deleting Original Data

Apr 19, 2013

I want to input data into text file while not deleting the original data in the file and I use something as

ofstream writefile;
writefile.open("example1.txt");
if (writefile.is_open()) {
for(j=0; j<N; j++) {

[Code] ....

But this will delete the original data.

View 3 Replies View Related

C++ :: Writing A Program To Calculate Grades

Apr 22, 2014

Writing a program to calculate grades... My algorithm is long, so I only posted the part that gives me trouble. When classes== 1,2,4, or 5, the program runs fine. but it terminates when classes == 3.

if (classes==3) {
do {
cout<<"Enter the Letter grade for 1st class. (USE CAPS)"<<endl;
cin>>grade1;

[Code].....

View 3 Replies View Related

C/C++ :: Program That Opens Text File And Checks Usernames Listed In Text Files?

Jun 5, 2014

I want to make a program that opens a text file and checks the usernames listed in the text files to see if the names are registered on a site such as twitter. How easy would this be to make, what things would I need to know?

View 4 Replies View Related

C++ :: Use Functions In A Program To Show Names And Grades

May 19, 2013

how to use functions in a program to show the names and grades of students, their average, total, highest and lowest grades.

View 1 Replies View Related

C++ :: Finding Program That Calculates Student Grades?

Jun 7, 2013

I have to make a program that reads two student grades, the average of the two has to be 6, if you can not take an average of 6, will make a third test and calculate a new average.

I'm not getting the new display medium, without repeating the approved and disapproved?

// TRABAV2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[]) {

[code]....

View 1 Replies View Related

C/C++ :: Quiz Show Game - Reset File To Original

Apr 7, 2015

I've been taking a C++ class, and for a project we need to do, we have to create a simple quiz show game while putting the high scores and names inside a .txt file. We have lessons we can look at to complete it while learning. But at the end there's always a challenge that we should complete to show that we've actually learned the information. For the challenge, we needed to take the information in the .txt file and reset it to its original information. So say there's 5 people preset that have high scores, then a person plays the game and the program asks if they'd like to reset the list. If the user inputted 'y' or any key that needed to be pressed, the program would reset the .txt to its original information.

This is the code that creates the program.

// Include Libraries
#include <iostream>
#include <string>
#include <fstream>
// Include standard namespace
using namespace std;
// Declare Global Variables
int Guess;
int Winnings;

[Code] ....

It works how I need it to and there aren't any problems, necessarily, but I want to know if there's any, more efficient, ways of completing this task. Like if there's any already made function of resetting a file.

This is the code that resets the file. As you can see, it just uses the information earlier in the code inside the if statement. Is there any pre-made function or method of resetting a file?

cout << "Would you like to reset the high scores list? (y or n): ";
cin >> ask;

if (ask == 'y')
{
High_Score[0] = 25000;
High_Score[1] = 12000;
High_Score[2] = 7500;
High_Score[3] = 4000;
High_Score[4] = 2000;

[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

Visual C++ :: Program Doesn't Accept Input Values True?

Nov 1, 2014

I am making a program which is going to print out a head image according to the input values entered by the user. Here is the code:

Code:
#include <iostream>
#include <string>
using namespace std;
void Sides()
// draws the sides to take proportion

[Code] .....

At first i tried to work program like:

Code:
cout << "plase enter which way you want to print out the head, with parted hair or bald." << endl;
cin >> headstyle;
if (headstyle != "bald" || headstyle != "parted hair" )

But it also had given the same mistake. The program compiles BUT; even if I put in the values bald or parted hair the program prints out "wrong input" then exits.

View 2 Replies View Related

C++ :: Program Compiles But Refuses To Print Out Char Grades?

Nov 10, 2014

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

using namespace std;

const int NAMESIZE = 15;
const int MAXRECORDS = 50;

[Code] ....

View 2 Replies View Related

C++ :: Program That Prompts User For 10 Grades And Then Find Average

Feb 24, 2015

I need to write a program that prompts the user for 10 grades and then find the average. I have that part but I need to average to not include -1. How can I tell the program to not calculate -1 into the average.

#include <iostream>
using namespace std;
int main() {
//Declare variables
float grade[10]; // 10 array slots
int count;
float total = 0;
double average;

[code].....

View 1 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 :: Predictive Text Program - Data Structure

Jan 19, 2014

Been given an assignment to create a predictive text program. What data structure I should use for this and the steps I should take when I make the program?

View 12 Replies View Related

C++ :: Data File Handling Error - Character Strings Not Copied On Text File

Nov 24, 2013

I have this code for a computer project... (store management) but the character strings are not copied on text file..

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
class Store {
public:
char *item_name[5];
store()

[Code] .....

Now when i run the program, it gives a error :::
ERROR
address 0x0

How can i write these strings to the text file?

View 2 Replies View Related







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