This is subject of C++
Your program should read the file answers.dat.
This file contains the name of the student who took the quiz, and
his answers for each question. The answers file has the following
format:
The correct answers to the quiz questions were:
Name your program pass1.cpp. Your program should meet the following requirements
The only change is that your name should be printed as the top label to indicate you were the developer.
/*******************
Pat Programmer
CSCI 2010 Section 03
Assignment 1
Programmed on Windows 7, Visual C++
This program does …
*******************/
You should obviously change the name to your name, the section to your section, the system to the system you used, and write a real description of the program
NOTE: You should not use pointers in this assignment. It is a review from last semester.
Sample Run
Suppose you have an answers.dat with these contents:
Elvis Presley
C++
for
if
variable
function
cheese
array
robots
reference
main
prototype
When you run your program, the output would be:
!!! Pat Programmer’s Most Excellent Quiz Reporter !!!
Report for Elvis Presley
CORRECT ANS STUDENT ANS
C++ C++
for for
if if
variable variable
function function
return cheese INCORRECT
array array
void robots INCORRECT
reference reference
main main
prototype prototype
QUIZ SCORE
81.82%
Note: Could you plz go this code and let me know if
u need any changes in this.Thank You
_________________
//answersFile.txt
Elvis Presley
C++
for
if
variable
function
cheese
array
robots
reference
main
prototype
__________________
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
//Declaring the function
void readAnswers(string answers[], int size, string&
name);
double calQuizScore(string questions[], string answers[], int
size);
void printReport(string questions[], string answers[], int size,
string name, double quizScore);
int main()
{
//defines an input stream for the data file
ifstream dataIn;
//setting the precision to two decimal places
std::cout << std::setprecision(2) << std::fixed;
//Declaring constants
const int size = 11;
string name;
//Declaring and initializing an array
string questions[] = { "C++", "for", "if", "variable", "function",
"return", "array",
"void", "reference", "main", "prototype" };
string answers[size];
//calling the functions
readAnswers(answers, size, name);
double quizScore = calQuizScore(questions, answers, size);
printReport(questions, answers, size, name, quizScore);
return 0;
}
/* This function will read the input file and
* populate the values into an array
*/
void readAnswers(string answers[], int size, string&
name)
{
string ans;
//defines an input stream for the data file
ifstream dataIn;
dataIn.open("answersFile.txt");
//checking whether the file name is valid or not
if (dataIn.fail()) {
cout << "** File Not Found **";
exit(0);
}
else {
getline(dataIn, name);
for (int i = 0; i < size; i++) {
getline(dataIn, ans);
answers[i] = ans;
}
dataIn.close();
}
}
// This function will calculate the quiz score
double calQuizScore(string questions[], string answers[], int
size)
{
double score = 0.0;
int cnt = 0;
for (int i = 0; i < size; i++) {
if (questions[i].compare(answers[i]) == 0)
cnt++;
}
score = ((double)cnt / size) * 100;
return score;
}
//This function will display the report
void printReport(string questions[], string answers[], int size,
string name, double quizScore)
{
cout << "\n\n!!! Pat Programmer’s Most Excellent Quiz
Reporter !!!" << endl;
cout << "Report for " << name << endl;
cout << "CORRECT ANS\tSTUDENT ANS" << endl;
for (int i = 0; i < size; i++) {
cout << setw(15) << left << questions[i] <<
setw(15) << left << answers[i];
if (questions[i].compare(answers[i]) != 0)
cout << setw(10) << right << "INCORRECT" <<
endl;
else
cout << endl;
}
cout << "QUIZ SCORE:" << quizScore
<<"%"<< endl;
}
_______________________
Output:

_______________Could you plz rate me well.Thank You
This is subject of C++ Your program should read the file answers.dat. This file contains the...
I need help writing c++ code to make this program. 1. Define a function that can read the input file answers.dat. This function should not print anything. 2. Define a function that computes the quiz score of the function by comparing the correct answers to the student’s answer. The result should be a percentage between 0 and 100, not a value between 0 and 1. This function should not print anything. 3. Define a function that prints the report as...
c++ program Notes 1. Your program should use named string constant for the file name to open the file. Do not add any path to the file name because the path on your computer is not likely to exist on the computer the instructor uses to grade the program. Points may be deducted if you don't follow this instruction. 2. Split statements and comments longer than 80 characters into multiple lines and use proper indentations for the split portions. 3....
Name your c++ file cpp. BScore_LastNameFirstName.cpp Write a program that contains a function call Input. The Input function should accept 2 decimal test scores that was entered from the user and stores them in an array. Don’t store any number less than 0. Return the array to main. Inside main, the program should pass the array and the total number of scores to countBGrade function. The countBGrade function should count how many B scores (80 to 89) were entered by...
Use
c++ as programming language. The file needs to be created ourselves
(ARRAYS) Write a program that contains the following functions: 1. A function to read integer values into a one-dimensional array of size N. 2. A function to sort a one-dimensional array of size N of integers in descending order. 3. A function to find and output the average of the values in a one dimensional array of size N of integers. 4. A function to output a one-dimensional...
In c++ Write a program that contains a class called Player. This class should contain two member variables: name, score. Here are the specifications: You should write get/set methods for all member variables. You should write a default constructor initializes the member variables to appropriate default values. Create an instance of Player in main. You should set the values on the instance and then print them out on the console. In Main Declare a variable that can hold a dynamcially...
The name of the C++ file must be search.cpp Write a program that will read data from a file. The program will allow the user to specify the filename. Use a loop that will check if the file is opened correctly, otherwise display an error message and allow the user to re-enter a filename until successful. Read the values from the file and store into an integer array. The program should then prompt the user for an integer which will...
C++ Write a function parseScores which takes a single input argument, a file name, as a string. Your function should read each line from the given filename, parse and process the data, and print the required information. Your function should return the number of student entries read from the file. Empty lines do not count as entries, and should be ignored. If the input file cannot be opened, return -1 and do not print anything. Your function should be named...
C++ 1. Your program should use named string constant for the file name to open the file. Do not add any path to the file name because the path on your computer is not likely to exist on the computer the instructor uses to grade the program. Points may be deducted if you don't follow this instruction. 2. Split statements and comments longer than 80 characters into multiple lines and use proper indentations for the split portions. (Lab2b.cpp) Write a...
Program in C Student Data using Structs In this assignment you will create a program (using multiple .c files) to solve the following problem: You have been hired by the university to create a program that will read in input from a .txt file. This input will contain a student name, student id #, their age and their current gpa. You should use the following struct for your student data: struct Student{ char name[50]; int id; float...
Using C programming For this project, you have been tasked to read a text file with student grades and perform several operations with them. First, you must read the file, loading the student records. Each record (line) contains the student’s identification number and then four of the student’s numerical test grades. Your application should find the average of the four grades and insert them into the same array as the id number and four grades. I suggest using a 5th...