Question
C++
please make it sifferent and unique

Description Write a program that will read data from the file p6.dat. The file (that you will create) always contains 15 te
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include<fstream>
#include<iomanip>
using namespace std;

int main()
{

  
char ch,fname[10];
int student[5][3],i=0,j=0,num=0,temp,best=0,F_grade=0;
double average_student[5],average_test[3],sum=0;
cout <<"Enter file name: ";
cin >> fname;
ifstream input(fname);
//loop to get the each input from file
while(input>>ch)
{
if(ch < '0' || ch > '9')
{
student[i][j] = num;
if(j==2)
{
j=0;
i++;
num=0;
continue;
}
j++;
num =0;
continue;
}
else
{
  
temp = ch - 48;
num = num * 10 + temp;
}
}
student[i][j] = num;
//loop to print average per student
cout <<"Average per student\n";
for(i=0;i<5;i++)
{
sum=0;
for(j=0;j<3;j++)
{
sum = sum + student[i][j];
}
average_student[i] = sum / 3;
cout <<"Student "<<(i+1)<<": "<<fixed<<setprecision(2)<<average_student[i]<<endl;
}
//loop to print average per test
cout <<"\nAverage per test\n";
for(i=0;i<3;i++)
{
sum=0;
for(j=0;j<5;j++)
{
if(best<student[j][i])
{
best = student[i][j];
}
if(student[i][j] <=59)
{
F_grade++;
}
sum = sum + student[j][i];
}
average_test[i] = sum / 5;
cout <<"Test "<<(i+1)<<": "<<fixed<<setprecision(2)<<average_test[i]<<endl;
}
  
cout <<"\nBest score: "<<best<<endl;
cout <<"\nF Grade scores: "<<F_grade;
  
//close the file
input.close();
return 0;
}

main.cpp p6.dat #include <iostream> #include<fstream> 3 #include<iomanip> 4 using namespace std; 2 #in 6 int main() char ch,temp = ch - 48; num = num * 10 + temp; 42 student[i][j] = num; // Loop to print average per student cout << Average per studaverage_test[i] = sum / 5; cout <<Test <<(i+1)<<: <<fixed<<setprecision (2)<<average_test[i]<<endl; cout <<\nBest score:

main.cpp p6.dat 1 60,70,80,74,64,84,90,65,45,78,92,49,85,76,82Enter file name: p6.dat Average per student student 1: 70.00 Student 2: 74.00 Student 3: 66.67 Student 4: 73.00 Student 5: 81

Add a comment
Know the answer?
Add Answer to:
C++ please make it sifferent and unique Description Write a program that will read data from...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Java program that reads a file until the end of the file is encountered....

    Write a Java program that reads a file until the end of the file is encountered. The file consists of an unknown number of students' last names and their corresponding test scores. The scores should be integer values and be within the range of 0 to 100. The first line of the file is the number of tests taken by each student. You may assume the data on the file is valid. The program should display the student's name, average...

  • Using C++. Please Provide 4 Test Cases. Test # Valid / Invalid Data Description of test...

    Using C++. Please Provide 4 Test Cases. Test # Valid / Invalid Data Description of test Input Value Actual Output Test Pass / Fail 1 Valid Pass 2 Valid Pass 3 Valid Pass 4 Valid Pass Question 2 Consider a file with the following student information: John Smith 99 Sarah Johnson 85 Jim Robinson 70 Mary Anderson 100 Michael Jackson 92 Each line in the file contains the first name, last name, and test score of a student. Write a...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • For this assignment, you are to write a program that does the following: (C++) • read exam scores...

    For this assignment, you are to write a program that does the following: (C++) • read exam scores from a file name data.txt into an array, and • after reading all the scores, output the following to the monitor: the average score and the total number of scores. In addition, the program must use the following functions: //precondition: fileName is name of the file to open, inFile is the input file 2 of 2 //postcondition: inFile is opened. If inFile...

  • Please help me with this program.You are to write a C++ program that will read in...

    Please help me with this program.You are to write a C++ program that will read in up to 15 students with student information and grades. Your program will compute an average and print out certain reports. Format: The information for each student is on separate lines of input. The first data will be the student�s ID number, next line is the students name, next the students classification, and the last line are the 10 grades where the last grade is...

  • C++ Data Structure Write a program to read a list of students from a file and...

    C++ Data Structure Write a program to read a list of students from a file and create a list. The program should use a linked list for implementation. Each node in the linked list should have the student’s name, a pointer to the next student, and a pointer to a linked list of scores. There may be up to four scores for each student.

  • Write a C program to compute average grades for a course. The course records are in...

    Write a C program to compute average grades for a course. The course records are in a single file and are organized according to the following format: Each line contains a student’s first name, then one space, then the student’s last name, then one space, then some number of quiz scores that, if they exist, are separated by one space. Each student will have zero to ten scores, and each score is an integer not greater than 100. Your program...

  • DESCRIPTION Complete the program using Java to read in values from a text file. The values...

    DESCRIPTION Complete the program using Java to read in values from a text file. The values will be the scores on several assignments by the students in a class. Each row of values represents a specific student's scores. Each column represents the scores of all students on a specific assignment. So a specific value is a specific student's score on a specific assignment. The first two values in the text file will give the number of students (number of rows)...

  • (C++ programming) Need help with homework. Write a program that can be used to gather statistical...

    (C++ programming) Need help with homework. Write a program that can be used to gather statistical data about the number of hours per week college students play video games. The program should perform the following steps: 1). Read data from the input file into a dynamically allocated array. The first number in the input file, n, represents the number of students that were surveyed. First read this number then use it to dynamically allocate an array of n integers. On...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT