Question

In C++. I'm not too sure how to start this. Any help would be appreciated. 1st picture is the problem. The 2nd is the data file.Write a routine that reads enrollment data about students in seven colleges for years 2010-2016 from a data file (problem 6.dproblem6.dat - Notepad File Edit Format View Help 100 110 121 133 146 160 176 22456 22551 22503 23004 23300 23556 23525 1234

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

#include<iostream>

#include<fstream>

using namespace std;

void input_routine(int dataArray[7][7])

{

ifstream inputFile; //Stream class to read from files

inputFile.open("problem6.dat"); //open input file

if(!inputFile)

{

cout<<"Can not open file!!"; // if file is not open then show FileIOError

exit(0);

}

for(int i=0;i<7;i++)

{

for(int j=0;j<7;j++)

{

inputFile>>dataArray[i][j]; //read data from data file and insert into array

}

}

}

void output_routine(int dataArray[7][7])

{

int totalPerCollege=0,totalPerYear=0;

printf("Collage NO.\t\t\t Number Of Students(2010-2016)\t\t\t Total per college\n");

for(int i=0;i<7;i++)

{

printf("%10d",i+1);

for(int j=0;j<7;j++)

{

totalPerCollege=totalPerCollege+dataArray[i][j]; //calculate total students per collage

printf("%10d",dataArray[i][j]); //print number of students enrolled per year

}

printf("%10d",totalPerCollege); //print total students per collage

totalPerCollege=0;

cout<<"\n";

}

printf("Total students\nper year ");

for(int j=0;j<7;j++)

{

for(int i=0;i<7;i++)

{

totalPerYear=totalPerYear+dataArray[i][j]; //calculate total students per year

}

printf("%10d",totalPerYear); //print total students per year

}

}

int main()

{

int dataArray[7][7]; // variable declaration

input_routine(dataArray); //call input_routine to read data into array

output_routine(dataArray);//call output_routine to print data

}

} 1 #include<iostream> 2 #include<fstream> 3 using namespace std; 4 void input_routine(int dataArray[7][7]) 5 { 6 ifstream in{ { mmmm } 25 for(int i=0;i<7;i++) 26 27 printf(%10d, i+1); 28 for(int j=0; j<7; j++) 29 30 totalPerCollege=totalPerCollege

Output

C:\Users\Pritam Mondal\Downloads\routine.exe Collage NO. Number of Students (2010-2016) 1 100 110 121 133 146 2 22456 22551 2

Input file

| 100 110 121 133 146 160 176 2 22456 22551 22503 23004 2330 23556 23525 3 1234 1345 1456 1567 1789 1890 1999 4 14321 4432 45

Add a comment
Know the answer?
Add Answer to:
In C++. I'm not too sure how to start this. Any help would be appreciated. 1st...
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
  • //please help I can’t figure out how to print and can’t get the random numbers to...

    //please help I can’t figure out how to print and can’t get the random numbers to print. Please help, I have the prompt attached. Thanks import java.util.*; public class Test { /** Main method */ public static void main(String[] args) { double[][] matrix = getMatrix(); // Display the sum of each column for (int col = 0; col < matrix[0].length; col++) { System.out.println( "Sum " + col + " is " + sumColumn(matrix, col)); } } /** getMatrix initializes an...

  • 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)...

  • Solve using visual basic, c#, or c++ 1. Write a program to do the Gauss Elimination...

    Solve using visual basic, c#, or c++ 1. Write a program to do the Gauss Elimination procedure for a set of simultaneous linear equations. The input is a comma separated file of numbers. Write the program in the following phases. Ensure each phase runs correctly before you proceed to the next phase. a. Write a computer program to open a.csv file, and read the contents an augmented matrix of n columns and n +1 rows. The program should display the...

  • ​​​​​​This program will make Maze game. Please Help in c++ Prompt the user for a file...

    ​​​​​​This program will make Maze game. Please Help in c++ Prompt the user for a file that contains the maze. Read it into a two-dimensional array Remember you can use inputStream.get(c) to read the next character from the inputStream. This will read whitespace and non-whitespace characters Don’t forget to read the newline character at the end of each line Print the maze to the screen from your array You should include a ‘*’ in your maze to indicate where the...

  • Please help i need a C++ version of this code and keep getting java versions. Please...

    Please help i need a C++ version of this code and keep getting java versions. Please C++ only Purpose: This lab will give you experience harnessing an existing backtracking algorithm for the eight queens problem, and seeing its results displayed on your console window (that is, the location of standard output). Lab A mostly complete version of the eight queens problem has been provided for you to download. This version has the class Queens nearly completed. You are to provide...

  • in c++ Purpose: This lab will give you experience harnessing an existing backtracking algorithm for the...

    in c++ Purpose: This lab will give you experience harnessing an existing backtracking algorithm for the eight queens problem, and seeing its results displayed on your console window (that is, the location of standard output). Lab A mostly complete version of the eight queens problem has been provided for you to download. This version has the class Queens nearly completed. You are to provide missing logic for the class Queens that will enable it to create a two-dimensional array that...

  • C++ Program - Arrays- Include the following header files in your program:     string, iomanip, iostream Suggestion:...

    C++ Program - Arrays- Include the following header files in your program:     string, iomanip, iostream Suggestion: code steps 1 thru 4 then test then add requirement 5, then test, then add 6, then test etc. Add comments to display assignment //step 1., //step 2. etc. This program is to have no programer created functions. Just do everything in main and make sure you comment each step. Create a program which has: 1. The following arrays created:                 a. an array...

  • C++ Help please- kind of long. The aim is to implement a seat reservation system for...

    C++ Help please- kind of long. The aim is to implement a seat reservation system for a passenger airplane. We assume a small airplane with 10 rows and 4 seats per row. We assume that the seat chart is initially stored in a file “chartIn.txt” in the following format: 1   A B C D 2   A B C D 3   A B C D 4   A B C D 5   A B C D 6   A B C D 7  ...

  • This is a C++ assignment that I'm trying to create and would like some help understanding...

    This is a C++ assignment that I'm trying to create and would like some help understanding while loops, with possible integration of for loops and if statements. This program only uses while, for, and if. I have some code that I have started, but where to go from there is what's giving me some trouble. This is involves a sentinel controlled while loop, and there are a lot of specifications below that I must have in the program. The program...

  • Need help with creating this JavaScript file. I'm not sure where or how to begin. 1. You are working solely with the DOM object. Thus, you should be coding primarily in the js file. You must use...

    Need help with creating this JavaScript file. I'm not sure where or how to begin. 1. You are working solely with the DOM object. Thus, you should be coding primarily in the js file. You must use the addEventListener, in addition you may need to use id and class attributes as needed. The .html and .css files have been provided to you. See the .png files for an example of what is expected. 2. Place the javaScript file in its...

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