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.
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
}
Output
Input file
In C++. I'm not too sure how to start this. Any help would be appreciated. 1st...
//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 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 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 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 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 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: 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 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 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 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...