Help on programing please.

closed account (zUC4izwU)
Can I have some help on my hw please.

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
timeframes 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.

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 should look something like this.

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



Oh yea I am using C++, and as of right now I'm not allowed to use anything but loops or if/elses. So no arrays.

Here is what I have so far can someone steer me in the right direction?

#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

int main()
{
ifstream inputFile;
string file;
int num;
int counter = 0;
int sum = 0;

cout << "Please enter a file : ";
cin >> file;
inputFile.open(file.c_str());
if(inputFile)
{
cout << "\t Project Completion Timetable" << endl << endl;
cout << setw(3) << "PHASE";
cout << setw(3) << "\t NUMBER OF TASK";
cout << " MAX TASK LENGTH" << endl << endl;
while(inputFile >> num)
{
cout << setw(3) << num << " ";
counter++;
if(counter%3 == 0)
{
cout << endl;
sum = sum + num;
}
if(counter%3 == 1)
{
cout << "\t\t";
}
if(counter%3 == 2)
{
cout << "\t\t";
}
}
cout << "Days for project completion : " << sum;
}
else
{
cout << "Error in opening the file. " << endl;
}
inputFile.close();

return 0;
}

Please use simple terms when explaining this for me, I'm not very good at this.
I'm on my iPod right now. Does this work? Seems like it does.
closed account (zUC4izwU)
As of right now everything is in place, but the data it is printing out is wrong. The output should only have one number of each phase. If there are 2 or more phase number it should display the number of phases in the second column instead of the task number. For the last column if there is more then one of the same phase it should print out the larger max task length of the 2. I missing steps to get to the output but I don't know where to even start.
Last edited on
A) the math is not there- for the "Days for Project completion", should be adding only the longest times for tasks in their respective phase. Not just adding all the lengths.

B)Should only be displaying one number for each phase- and tell how many tasks in each phase. ex:
Phase / Tasks / Length
1 ---> 2 ---> 5

C) Shouldnt even be displaying the task numbers (if I understand right) just the number of tasks within each phase.

Try that and post what you come up with.
closed account (zUC4izwU)
I know all of that already I just don't know how to write the code doing that.
Topic archived. No new replies allowed.