Search Tutorials

Loading...

Thursday, 16 May 2013

C code of stage-1 of Cocomo-2 Model

//C program to calculate effort and productivity in stage-1 of cocomo-2 model//

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
  int no_of_screens,no_of_reports;
  int screen[4],report[4];
  int CPLX_table[3][3]={
                {0,0,1},     //0-Small
                {0,1,2},     //1-Medium
                {1,2,2}      //2-Difficult
              };
  int weight_table[3][3]={
                {1,2,3},
                {2,5,8},
                {-1,-1,10}
              };
  int col,r_row,s_row,s_CPLX,r_CPLX;
  int rating,OP,reuse;
  float NOP,effort;
  int PROD[5]={4,7,13,25,50};

  clrscr();

  printf("\nEnter number of Screens : ");
  scanf("%d",&screen[0]);

  printf("\nEnter number of Screen Views : ");
  scanf("%d",&screen[1]);

  printf("\nEnter number of clients and servers : ");
  scanf("%d %d",&screen[2],&screen[3]);

  printf("\nEnter number of Reports : ");
  scanf("%d",&report[0]);

  printf("\nEnter number of Report Sections : ");
  scanf("%d",&report[1]);

  printf("\nEnter number of clients and servers : ");
  scanf("%d %d",&report[2],&report[3]);


  if(screen[1]<3)
    s_row=0;
  else if(screen[1]>=3 && screen[1]<=7)
    s_row=1;
  else if(screen[1]>=8)
    s_row=2;

  if(report[1]==0 || report[1]==1)
    r_row=0;
  else if(report[1]==2 || report[1]==3)
    r_row=1;
  else if(report[1]>=4)
    r_row=2;

    if(screen[2]<2 && screen[3]<3)
      col=0;
    else if((screen[2]>=2 && screen[2]<=3) && (screen[3]>=3 && screen[3]<=5))
      col=1;
    else if(screen[2]>3 && screen[3]>5)
      col=2;

  s_CPLX=CPLX_table[s_row][col];
  r_CPLX=CPLX_table[r_row][col];

  OP=(screen[0]*weight_table[0][s_CPLX])+(report[0]*weight_table[1][r_CPLX]);
  printf("\nObject Point = %d",OP);
  printf("\nEnter Reuse % : ");
  scanf("%d",&reuse);
  NOP=(OP*(100-reuse))/100.0;
  printf("\nNew Object Point (NOP) = %f",NOP);
  printf("\nRate Programmer's Capability and Experience on Scale of 0-4 :\n");
  printf("\n0 - Very Low\n1 - Low\n2 - Nominal\n3 - High\n4 - Very High\n\n");
  scanf("%d",&rating);
  printf("\nProductivity = %d",PROD[rating]);
  effort=NOP/PROD[rating];
  printf("\n\nEffort = NOP/Productivity");
  printf("\nEffort = %f",effort);
getch();
}

No comments:

Post a Comment

Back to Top