1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#include <stdio.h>
int main( void )
{
unsigned int counter;
int projectnumber;
int optimistictime;
int realistictime;
int pessimistictime;
int longesttime;
int longestproject;
int ask;
float expectedtime;
counter = 0;
expectedtime = 0;
//getfirstproject
printf( "%s", "Would you like to calculate the expected time for an Activity?\n1 for yes, -1 for no: ");
scanf( "%d", &ask);
longestproject = 0;
longesttime = 0;
while ( ask > 0 ) {
printf( "%s", "Enter Project Number: " );
scanf( "%d", &projectnumber);
printf( "%s", "Enter Optimistic Time(in weeks): " );
scanf( "%d", &optimistictime);
printf( "%s", "Enter Realistic Time(in weeks): " );
scanf( "%d", &realistictime);
printf( "%s", "Enter Pessimistic Time(in weeks): " );
scanf( "%d", &pessimistictime);
counter = counter + 1; // increment counter
//calculate and display information
printf("The Project Number is %d\n", projectnumber);
printf("The Optimistic Time is %d\n", optimistictime);
printf("The Realistic Time is %d\n", realistictime);
printf("The Pessimistic Time is %d\n", pessimistictime);
expectedtime = (float) (optimistictime + 4*realistictime + pessimistictime)/6;
printf("The Expected Time is %.1f\n", expectedtime);
if (expectedtime > longesttime)
{
expectedtime = longesttime;
longestproject = projectnumber;
}
else {
}
printf( "%s", "Would you like to calculate the expected time for an Activity?\n1 for yes, -1 for no: ");
scanf( "%d", &ask);
} // end while
while (ask < 0 ) {
printf("The Number of Records Processed is: %d\n", counter );
printf("The Project Number with the Longest Expected time is: %d\n", longestproject);
system("PAUSE");
return 0;
}
}
|