0 Replies - 495 Views - Last Post: 10 December 2005 - 05:17 PM Rate Topic: -----

#1 Kevin Beecher   User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 10-December 05

Price Elasticity of Demand Program

Posted 10 December 2005 - 05:17 PM

Description: just enter the original quantity demanded, then the new, then enter your original price, then the new price.This is my first 'good program' as I have just started C, what this program does is it works out how Elastic / Inelastic a Demand Curve (this relates to economics), Enjoy!
#include<stdio.h>
#include<conio.h>
#include<math.h>

int main (int args,char ** argc){ 
     printf("***Price Elasticity of Demand Program v2.5***");
     printf("Developed by Kevin Beecher (c)");
     printf("n_____________________________________________nnn");
     //declaration of variables
           double nQ1,nQ2,nP1,nP2,nChgQ,nChgP,nSec1,nSec2,nResult1,nResult2,nElasticity;
          char quit;
               do {
     //read the input
          printf("Quantity 1 = ");scanf("%lf",&nQ1);
           printf("nQuantity 2 = ");scanf("%lf",&nQ2);
          printf("nnPrice 1 = ");scanf("%lf",&nP1);
          printf("nPrice 2 = ");scanf("%lf",&nP2);

     //output
               nChgQ = nQ2-nQ1;
               nChgP = nP2-nP1;
                    
                    printf("nnThe Change in Quantity is %lfnn",nChgQ);
                    printf("nnThe Change in Price is %lfnn",nChgP);

               nSec1 = (nQ1+nQ2) / 2;
               nSec2 = (nP1+nP2) / 2;
               
               nResult1 = nChgQ / nSec1;
               nResult2 = nChgP / nSec2;

               nElasticity = nResult1 / nResult2;

     //result
                    printf("nn______________nn");
                    printf("The Price Elasticity of Demand is %lfnnnnn",nElasticity);

                    if(nElasticity==-1 || nElasticity==1)
               {
                    printf("This is Unitary Elasticnnn");
               }
                    if(nElasticity<1 && nElasticity>-1)
               {
                    printf("This is Inelasticnnn");
               }
                    if(nElasticity>1 || nElasticity<-1)
               {
                    printf("This is Elastic");
               }
                    if(nElasticity==0)
               {
                    printf("Inelastic");
               }
                    
               printf("nn______________________nnn");               
               printf("Do you want to quit? (y/n)  ");
                         scanf("%s", &quit);
                         printf("nnnn");
     }
               while (quit == 'N' || quit == 'n');
     
return 1;
}



Is This A Good Question/Topic? 0
  • +

Page 1 of 1