-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha1_functions.c
131 lines (101 loc) · 2.59 KB
/
a1_functions.c
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/********* definitions.c ********
Student Name = Kalid Wehbe
Student Number = 101259994
*/
#include <stdio.h>
#include "a1_data_structures.h"
#include <math.h>
#include "a1_functions.h"
milestone_t init_milestone(char stage_name[], float assigned_budget)
{
milestone_t newMilestone;
strcpy(newMilestone.name, stage_name);
// Initialize other fields
newMilestone.cost = assigned_budget / 5.0;
newMilestone.time = 0.0;
newMilestone.num_employees = 0;
newMilestone.completed = 0;
return newMilestone;
}
unsigned short int get_input_usi(void)
{
int number;
scanf("%d", &number);
return number;
}
float get_input_f(void)
{
float f_num = 0.0;
do
{
scanf("%f", &f_num);
if (f_num < 0)
{
printf("The value you entered is wrong.\n");
printf("Enter a positive value: ");
}
} while (f_num < 0);
return f_num;
}
void number_of_employees(milestone_t *project_details)
{
float salary = project_details->time * hours * pay;
float num_employees = project_details->cost / salary;
int num_employees_int = round(num_employees);
printf("The planned number of employees needed is %d\n", num_employees_int);
}
void print_menu(void)
{
printf("Which milestone you want to update? (0 to exit): \n");
printf("1. Technical requirements\n");
printf("2. System Design\n");
printf("3. Software Development\n");
printf("4. Testing\n");
printf("5. Product release\n");
}
void print_stats(milestone_t details)
{
printf("Actual time %.2f\n", details.time);
printf("Actual number of employees %d\n", details.num_employees);
printf("Actual cost %.2f $\n", details.cost);
if (details.completed == 0)
{
printf("Completed: No\n");
}
else
{
printf("Completed: Yes\n");
}
}
void update_stats(milestone_t milestone_array[], int milestone_num)
{
printf("Enter the milestone's actual time: ");
milestone_array[milestone_num].time = get_input_f();
printf("Enter the milestone's actual number of employees: ");
milestone_array[milestone_num].num_employees = get_input_usi();
char choice;
printf("Is this milestone's complete?: (Y/N) ");
scanf(" %c", &choice);
if (choice == 'Y')
{
milestone_array[milestone_num].completed = 1;
}
else
{
milestone_array[milestone_num].completed = 0;
}
milestone_array[milestone_num].cost = milestone_array[milestone_num].time * milestone_array[milestone_num].num_employees * hours * pay;
}
void check_project_completion(milestone_t milestone_array[], int num_milestones)
{
milestone_array[0].completed = 1;
int i;
for (i = 1; i < num_milestones; i++)
{
if (milestone_array[i].completed == 0)
{
milestone_array[0].completed = 0;
break;
}
}
}