Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the following code Use the following file as data input for your projec

ID: 3685702 • Letter: C

Question

Complete the following code

Use the following file as data input for your project:

You will read the contents of an input file and write those contents into an output file. Your output file should be a column-aligned text file.

The file read is already performed in the code I provided, but it only reads the first line. You will need to modify it so that it reads the entire file (5 lines total). And I did not provide the file write code. Remember to close the files when you are done with them.

Your program should perform the following tasks:

After the array has been loaded, open an output text file and write the contents of the array to the file.

The file should be column-aligned with the names of the taxonomic ranks as column headers.

Finish the following code

#include "stdafx.h"
#include
#include
#include
#include
#include

using namespace std;

string Comman_Name;
string Domain;
string Kingdom;
string Phylum;
string Class;
string Order;
string Family;
string Genus;
string Species;


int _tmain(int argc, _TCHAR* argv[])
{


   ifstream inFile;
   string szSourcePath =           // path of input file, change to your file location
       "c:\CIS022_S2016_Assignment9a.txt";


   inFile.open(szSourcePath);

   inFile >>
       Comman_Name >>
       Domain >>
       Kingdom >>
       Phylum >>
       Class >>
       Order >>
       Family >>
       Genus >>
       Species;

   inFile.close();

   system("pause");
   return 0;
}

A. Create a struct data type that contains a string variable for each of the taxonomic ranks.

Create an array of that type with 5 elements. B. Read the input file into the array. C.

After the array has been loaded, open an output text file and write the contents of the array to the file.

The file should be column-aligned with the names of the taxonomic ranks as column headers.

Finish the following code

#include "stdafx.h"
#include
#include
#include
#include
#include

using namespace std;

string Comman_Name;
string Domain;
string Kingdom;
string Phylum;
string Class;
string Order;
string Family;
string Genus;
string Species;


int _tmain(int argc, _TCHAR* argv[])
{


   ifstream inFile;
   string szSourcePath =           // path of input file, change to your file location
       "c:\CIS022_S2016_Assignment9a.txt";


   inFile.open(szSourcePath);

   inFile >>
       Comman_Name >>
       Domain >>
       Kingdom >>
       Phylum >>
       Class >>
       Order >>
       Family >>
       Genus >>
       Species;

   inFile.close();

   system("pause");
   return 0;
}

Explanation / Answer

//#include "stdafx.h"
#include<iostream>
#include<fstream>


using namespace std;

struct taxonomic{
   string Comman_Name;
   string Domain;
   string Kingdom;
   string Phylum;
   string Class;
   string Order;
   string Family;
   string Genus;
   string Species;
};


int _tmain(int argc, char *argv[])
{


   ifstream inFile;
   // path of input file, change to your file location
   char szSourcePath[] = "c:\CIS022_S2016_Assignment9a.txt";

   taxonomic arr[5];

   inFile.open(szSourcePath);
   int i=0;
   while(i < 5){

   inFile >>
       arr[i].Comman_Name >>
       arr[i].Domain >>
       arr[i].Kingdom >>
       arr[i].Phylum >>
       arr[i].Class >>
       arr[i].Order >>
       arr[i].Family >>
       arr[i].Genus >>
       arr[i].Species;
       i++;
   }

   inFile.close();

   // now writing to file

   char outputFile[] = "c:\CIS022_S2016_Assignment9b.txt"; // here mention your output file path
   ofstream outFile;
   outFile.open(outputFile);


   i=0;
   while(i<5){
   outFile <<
       arr[i].Comman_Name <<
       arr[i].Domain <<
       arr[i].Kingdom <<
       arr[i].Phylum <<
       arr[i].Class <<
       arr[i].Order <<
       arr[i].Family <<
       arr[i].Genus <<
       arr[i].Species<<endl;
      
   }
  
   outFile.close();

   //system("pause");
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote