Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I need help with c++ and will try my best to explain the problem. I don't need a whole code written, just some help

Hello, I need help with c++ and will try my best to explain the problem. I don't need a whole code written, just some help on my output. Basically i have to read in data from a text file and print out data. Below is my code and the text file im reading in from, probably not the best coding you'll see but I'm not an expert.

#include #include #include #include #include"Header.h" using namespace std; int i; void printEachTime(); void LinesOfCode(int a, int b,int c); //for each person, there info int OnetoK(); void print(); Programmers prog[11] = { 0 }; int main() { ifstream in; ofstream out; in.open("Text.txt"); //open this files out.open("output.txt"); //prepare the file to hold the output data

while (in >> i >> prog[i].totallines >> prog[i].totalcomments) //while line in has the i programmer number, prog i numb lines, prog i comments, do this { LinesOfCode(i, prog[i].totallines, prog[i].totalcomments); //call lines of code to count total lines of comments and lines printEachTime(); //print each time to print each persons progress } print(); //print final results, should also call the function that sees how many people it would take to reach 1000 in.close(); out.close();

system("pause"); return 0; }

void LinesOfCode(int a, int b, int c){ int temp=a; //set temp equal to programmer number int templines=b; //set this equal to the programmers total lines int tempcomments=c; //set this equal to programmers total comments while (prog[temp].totallines

tempcomments += prog[temp].totalcomments; prog[temp].totalcomments = tempcomments;

//printEachTime(); break; } }

void printEachTime() { //for printing out the persons information each time ifstream in; ofstream out; in.open("Text.txt"); //open this files out.open("output.txt"); int m = 1;

cout

TEXT FILE:

10 230 100 8 206 120 7 111 50 3 159 56 9 336 200 1 51 10 10 250 123 4 101 29 9 341 190 2 105 43 8 256 122 10 320 120 3 150 19 5 215 98 7 222 108 9 400 210 10 330 125

basically my issue is, the output doesnt start with the first line in the text file. Each line for the output doesnt correspond to the right line in the text file. For example in line 1 of the data file its 10 230 and 100, in the output it says 10, 206, 120; which is the seconds line information in the input file. Hope that makes sense.

image text in transcribed

Please help me resolve the issue.

image text in transcribed
Users user sources C326-FEBE%Debug C2-LA.ee Programmer Axecutable lines caments Prverarmer 1 Programmer 2 Proererner 3 Programmer 4 Programmer 5 Programmer G Programmer 7 Programmer Programmer 9 Programmer 18 Programmer executable lines Connent: Programmer i Proerrer 2 Programmer Programmer 4 Programmers Programmer 6 Programmer 7 Programmer Programmer o Programmer 10 280 128 Prrerarmer Perutable lines 3 Prcerarmer 1 Programmer 2 Programmer 3 Programmer 4 Programmer S Programmerd Programmer / Programmer 8 Programmer 9 Programmer 18 3 111 se 266 129 Programmer cxecutable lines connents Programmer Programmer Programmer 3 Programmer 4 Programmer 5 Programmer o Programmer 7 Programmer 8 Programmer Programmer 10 150 111 56 50 205 Type here to search O 10 12:40 PM 2/15/2001 D SCHestone relepo.325 FEBB Debug CSCLAT Programmer executable lines comments Programmer 1 Programmer 2 Programmer 3 Programmer 4 Programmer 5 Programmer 6 Programmer 7 Programmer 8 Programmer 9 Programmer 10 206 120 Programmer executable lines comments Programmer 1 Programmer 2 Programmer 3 Programmer 4 Programmer 5 Programmer 6 Programmer 7 Programmer 8 Programmer 9 Programmer 10 111 50 206 120 Programmer executable lines Comments Programmer Programmer 2 Programmer 3 Programmer 4 Programmer 5 Programmer 6 Programmer 7 Programmer 8 Programmer 9 Programmer 10 159 111 56 se 206 120 executable lines comments 336 200 Programmer Programmer 1 Programmer 2 Programmer 3 Programmer 4 Programmers Programmer 6 Programmer 7 Programmer B Programmer 9 Programmer 10 @ 159 111 e 56 se 206 120

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1. How have friends influenced past purchases you have made?

Answered: 1 week ago

Question

Is the person willing to deal with the consequences?

Answered: 1 week ago

Question

Was there an effort to involve the appropriate people?

Answered: 1 week ago