Creating a Test Input File

Hey all,

I'm currently a student in college, taking the first of many programming classes. So far I understand c++ a good amount and am catching on pretty quick. BUT we got this assignment and I honestly don't quite understand it. I also just want to say that I'm not here for a quick answer. I just would like some help with explaining it so I can better understand how to start and what to actually do. Some hints and help, kinda like an online tutor. I decided to post the whole thing so you could see what exactly is going on.. sorry for the length.

So I understand he's asking us to make a "test input file" using a txt editor, but all I really understand is that the program will be reading the txt file. I don't get how to calculate what he's asking or really quite how to make it..
So any help to get the ball rolling would be greatly appreciated! :)

Assignment
A project is comprised of one or more sequential phases. Each phase is comprised of one or more
tasks. Each phase must be completed before the next one can begin. However, the different tasks
belonging to a single phase can be carried out concurrently. The time it takes to complete a phase
is the time needed to complete the longest task in that phase.
You are to write a program that analyzes the phases of a project and provides a summary of the
time frames for the phases and the entire project.
The program will read the information regarding the project phases and tasks from an input file.
The output of the program should be directed to the standard output device.

The Input File
You are to create a test input file using a standard text editor. Each line of the file contains an
phase number, a task number, and the number of days required to complete the task. All values
should be integers and the values on each line should be separated by a space.
The data are stored such that all the tasks for phase 1 are followed by all the tasks for phase 2, and so on.

A typical data file for a project might contain the following data:
1 100 6
1 110 4
2 120 5
3 130 4
3 140 1
4 150 2
4 160 3
4 170 3
5 180 2
5 190 12
6 200 5

So, for example, phase 3 for this project is comprised of two tasks. The time needed to complete
phase 3 is four days (the length of the longest task for phase 3).
The Output
The program should print a project timetable summary that lists each phase number, a count of
the number of tasks within the phase, the maximum number of days for a task within the phase,
and the total number of days for the project completion.

An example might be:

PROJECT COMPLETION TIMETABLE
PHASE / NUMBER OF TASKS / MAX TASK LENGTH
----- --------------- ---------------
1 / 2 / 6
2 / 1 / 5
3 / 2 / 4
4 / 3 / 3
5 / 2 / 12
6 / 1 / 5

Days for project completion: 35

Requirements
• You must prompt the user for a file name and you must read your input values from that file.
• You must detect failures in opening the input file.
• You must use end of file detection to determine when to stop reading from the file. Do not loop through a fixed number of times.
Last edited on
When he says "test input file", he means do the following:

1. Open notepad.exe.
2. Copy the data shown above into notepad.exe
3. Save as "SomeName.txt"
4. Stick this file in the same directory as your .exe that will be created

In the code create: std::ifstream("SomeName.txt");
Now you are reading that file into your code.
There are a lot of words there. It may help if you take a sheet of paper and draw a diagram representing each phase and the time required. They do say a picture paints a thousand words, and it should help to clarify the meaning.
Definitely lots of words. Part of the reason why I'm confused when I read it I just get lost.
But I get that you have to tell it to read the .txt file, however I dont get quite how to print it so it appears the way he wants in the timetable format above. Any other suggestions, maybe a couple lines of code to show me what you mean?

thx
tmort92, here is my take on your assignment. I've appended some more input data from your example.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1 100 6 
1 110 4 
2 120 5 
3 130 4 
3 140 1 
4 150 2 
4 160 3 
4 170 3 
5 180 2 
5 190 12 
6 200 5 
7 101 44
7 102 44
7 103 543
7 104 45
7 105 88


PROJECT COMPLETION TIMETABLE

1
2
3
4
5
6
7
8
9
10
11
12
P = PHASE 
T = NUMBER OF TASKS 
L = MAX TASK LENGTH 

P / T / L
1 / 2 / 6 
2 / 1 / 5 
3 / 2 / 4 
4 / 3 / 3 
5 / 2 / 12 
6 / 1 / 5
7 / 5 / 543


It looks like he wants the ouput to summarize
the number of tasks in a phase and the length of the task. I added a phase 7 to the example.
So from the output each line is like this:

phase number / (the count of steps in this phase) / (the max value for this phase)

taking example phase 7 for example
1
2
3
4
5
7 101 44
7 102 44
7 103 543
7 104 45
7 105 88

the line generated would be
7 / 5 / 543 because phase 7 has 5 lines of steps, and the maximum value for the last column is 543.

If all else fails, its Wednesday, you should track down your instructor and ask him to clarify his specifications if you're still confused.

I hope this helps,
Last edited on
Topic archived. No new replies allowed.