Untitled
unknown
c_cpp
a year ago
1.8 kB
3
Indexable
#include <bits/stdc++.h>
using namespace std;
// Function to round a float to the nearest integer
int fround(float x)
{
x = x + 0.5; // Add 0.5 to round to the nearest whole number
int a = static_cast<int>(x); // Convert to integer
return a;
}
// Function to calculate and display effort, development time, and staff required
void calculate(float table[][4], int n, string mode[], int size)
{
float effort, time, staff;
int model;
// Determine the model based on the size
if (size >= 2 && size <= 50)
model = 0; // Organic model
else if (size > 50 && size <= 300)
model = 1; // Semi-Detached model
else if (size > 300)
model = 2; // Embedded model
// Calculate effort, development time, and staff using COCOMO formulas
effort = table[model][0] * pow(size, table[model][1]);
time = table[model][2] * pow(effort, table[model][3]);
staff = effort / time;
// Display the results
cout << "The mode is " << mode[model] << endl;
cout << "Effort = " << effort << " Person-Months" << endl;
cout << "Development Time = " << time << " Months" << endl;
cout << "Average Staff Required = " << fround(staff) << " Persons" << endl;
}
int main()
{
// Coefficients for COCOMO model (Organic, Semi-Detached, Embedded)
float table[3][4] = {
{2.4, 1.05, 2.5, 0.38}, // Organic
{3.0, 1.12, 2.5, 0.35}, // Semi-Detached
{3.6, 1.20, 2.5, 0.32} // Embedded
};
// Models names
string mode[] = {"Organic", "Semi-Detached", "Embedded"};
int size = 4; // Size of the software project (in KLOC)
// Call the calculate function to estimate effort, time, and staff
calculate(table, 3, mode, size);
return 0;
}
Editor is loading...
Leave a Comment