-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
148 lines (135 loc) · 2.78 KB
/
main.go
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package main
import (
"fmt"
"math"
"strconv"
"github.com/irksome0/cocomoApplication/data"
)
func main() {
var modelType string
for {
fmt.Print("Enter a model type(basic/intermediate)\n B/I : ")
fmt.Scan(&modelType)
switch modelType {
case "B":
basicModel()
return
case "I":
intermediateModel()
return
default:
fmt.Println("Try again...")
}
}
}
func basicModel() {
var projectType string
var coefficients [4]float32
for {
fmt.Print("Enter a project type(organic/semidetach/embedded)\n O/S/E : ")
fmt.Scan(&projectType)
flag := false
switch projectType {
case "O":
coefficients = data.BASIC["ORGANIC"]
flag = true
break
case "S":
coefficients = data.BASIC["SEMIDETACH"]
flag = true
break
case "E":
coefficients = data.BASIC["EMBEDDED"]
flag = true
break
default:
fmt.Println("Try again...")
}
if flag {
break
}
}
var SIZE string
fmt.Print("What's the size of program: ")
fmt.Scan(&SIZE)
size, err := strconv.ParseFloat(SIZE, 64)
if err != nil {
panic(err)
}
PM := float64(coefficients[0]) * math.Pow(size, float64(coefficients[1]))
TM := float64(coefficients[2]) * math.Pow(PM, float64(coefficients[3]))
SS := PM / TM
P := size / float64(PM)
fmt.Printf("Labor intensity: %f\nDevelopment duration: %f\nAmount of developers: %f\nEfficiency: %f\n", PM, TM, SS, P)
}
func intermediateModel() {
var CD = make([]string, 15, 15)
var projectType string
var coefficients [2]float32
var SIZE string
for {
fmt.Print("Enter a project type(organic/semidetach/embedded)\n O/S/E : ")
fmt.Scan(&projectType)
flag := false
switch projectType {
case "O":
coefficients = data.INTERMEDIATE["ORGANIC"]
flag = true
break
case "S":
coefficients = data.INTERMEDIATE["SEMIDETACH"]
flag = true
break
case "E":
coefficients = data.INTERMEDIATE["EMBEDDED"]
flag = true
break
default:
fmt.Println("Try again...")
}
if flag {
break
}
}
fmt.Print("What's the size of program: ")
fmt.Scan(&SIZE)
size, err := strconv.ParseFloat(SIZE, 64)
if err != nil {
panic(err)
}
fmt.Print("Enter coefficients(1-6): \n")
for i := 0; i < 15; i++ {
fmt.Print(data.ATTRIBS[i] + ": ")
var temp string
fmt.Scan(&temp)
switch temp {
case "1":
CD[i] = "VERY LOW"
break
case "2":
CD[i] = "LOW"
break
case "3":
CD[i] = "INTERMEDIATE"
break
case "4":
CD[i] = "HIGH"
break
case "5":
CD[i] = "VERY HIGH"
break
case "6":
CD[i] = "CRITICAL"
break
default:
CD[i] = "INTERMEDIATE"
break
}
}
productOfCoefs := 1.0
for i := 0; i < 15; i++ {
productOfCoefs *= data.ATTRIBUTES[data.ATTRIBUTES_TAGS[i]][CD[i]]
}
PM := productOfCoefs * float64(coefficients[0]) * math.Pow(size, float64(coefficients[1]))
fmt.Printf("Labor intensity: %f\n", PM)
}