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
|
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
//Company.header
class Company{
private: double *charges, *weight, *output;
public:
void corrier
( double &max_charges, double ¤t_weight, double &output, double min_charges, double default_weight);
};
//Corrier.cpp
void Company::corrier
(double &max_charges,double ¤t_weight, double &output, double min_charges, double default_weight)
{
weight = 0;
weight = new double;
*weight = current_weight;
current_weight = 1000;
weight = 0;
weight = new double;
*weight = default_weight;
default_weight = 1;
charges = 0;
charges = new double;
*charges = max_charges;
max_charges = 15.00;
charges = 0;
charges = new double;
*charges = min_charges;
min_charges = 1.50;
printf(" Please enter weight in kg: ");
string input;
getline(cin, input);
current_weight = stod(input);
if(max_charges >= current_weight){
output = max_charges + current_weight;
printf("The weight of the parcel is %f\n ",output);
cout << "The weight of the parcel is " <<
output << current_weight << endl;
}else if(max_charges<current_weight)
{
output = min_charges * default_weight;
printf("The weight of the parcel is %f\n ",output);
cout << "The weight of the parcel is** " <<
output << endl;
}
};
//main.cpp
int main(){
Company Employee;
double max_weight;
double current_charges;
double output;
double min_charges;
double default_weight;
Employee.corrier(max_weight, current_charges, output,min_charges, default_weight);
return 0;
}
|