Showing posts with label Calculate publishing conference cost. Show all posts
Showing posts with label Calculate publishing conference cost. Show all posts

Calculate the cost of publishing conference

#include<iostream.h>
#include<string.h>
#include<conio.h>
#include<stdio.h>
const int std_size=15;
const float std_cost=5;
const float penalty=0.5;
class paper;
float totalcost(paper*,int);
class paper
{
char author[25];
int page;
   public:
paper()
{
author[0]='\0';
page=0;
}
paper(char a[],int p)
{
strcpy(author,a);
page=p;
}
void input();
float papercost();
};
void paper::input()
{
cout<<"\nEnter name of the author : ";
gets(author);
cout<<"\nEnter number of pages in his research paper : ";
cin>>page;
}
float paper::papercost()
{
int extra;
float cost;
if(page<=std_size)
return page*std_cost;
else
{
extra = page - std_size;
cost  = (std_size*std_cost) + extra*(std_cost + penalty);
return cost;
}
}
int main()
{
int count;
paper *conf;
cout<<"Enter total number of papers : ";
cin>>count;
cout<<"\nEnter details of the papers\n";
cout<<"---------------------------\n";
conf = new paper[count];
for(int i=0;i<count;i++)
conf[i].input();
cout<<"\n\nThe total cost of publishing is : Rs."<<totalcost(conf,count);
delete conf;
return 0;
}
float totalcost(paper *p,int n)
{
float tcost=0;
for(int i=0;i<n;i++)
{
tcost +=  p[i].papercost();
}
return tcost;
}


Output:
Enter total number of papers : 2

Enter details of the papers
---------------------------
Enter name of the author :
Enter number of pages in his research paper : 3
Enter name of the author :
Enter number of pages in his research paper : 3
The total cost of publishing is : Rs.30

Labels