You have just started your new job as a junior programmer at Wrightâs Design Hou
ID: 3551972 • Letter: Y
Question
You have just started your new job as a junior programmer at Wrightâs Design House. The Project Manager has asked you to develop a program to determine the estimated time needed to complete a design project. To determine the estimated time the Design House uses the calculations entered for an optimistic time, a realistic time and a pessimistic time. The program allows the staff to enter and keep track of the number of projects, then prints the results based on the data entered.
Data Entry
A five digit project number
A two digit optimistic time
A two digit realistic time
A two digit pessimistic time
Data Output
Each project number
The optimistic time
The realistic time
The pessimistic time
The expected time use the formula ET = ( OT + 4RT + PT) / 6
The total number of projects and the activity that takes the longest time and the activity that takes the shortest time.
Explanation / Answer
#include <stdio.h>
#include <limits.h>
int main()
{
int N = 0; //The number of projects
char key; //Key to continue the program
printf("USAGE: Press 'q' to stop the data entering, any other key to continue ");
scanf("%c", &key);
long int min_time_project = LONG_MAX;
long int max_time_project = LONG_MIN;
float min_time = LONG_MAX;
float max_time = LONG_MIN;
while(key !='q')
{
long int PN; //Enter a five digit Project number
float OT,RT,PT; //OT: Optimistic Time | RT: Realistic Time | PT: Pessimistic Time
printf("Enter the Project Number: ");
scanf("%ld",&PN); //Takes the project number
printf("Enter the Optimistic time: ");
scanf("%f",&OT); //Takes the Optimistic Time
printf("Enter the Realistic time: ");
scanf("%f",&RT); //Takes the Realistic Time
printf("Enter the Pessimstic time: ");
scanf("%f",&PT); //Takes the Pessimistic Time
float ET = float(OT+4*RT+PT)/6.0; //Calculates the Estimated time
if(ET<min_time)
{
min_time_project = PN;
min_time = ET;
}
if(ET>max_time)
{
max_time_project = PN;
max_time = ET;
}
N = N+1; //Increment the project number counter
printf("To stop press 'q', otherwise press any other key: ");
scanf(" %c", &key);
}
printf("The total number of projects: %d ", N);
printf("The activity that takes the longest time: %ld ",max_time_project);
printf("The activity that takes the shortest time: %ld ", min_time_project);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.