0% found this document useful (0 votes)
8 views6 pages

OOP (Lab) Assignment

Uploaded by

saadalimubarack
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views6 pages

OOP (Lab) Assignment

Uploaded by

saadalimubarack
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Name:

Saad Ali Mubarak


Roll Number:
222201017
Class:
BSCS 2
Submitted to:
Ma’am Rida Bajwa

ASSIGNMENT NO.1

#include<iostream>

#include<string>

using namespace std;

class package

private:

string sender, receipt;

double weight, costperounce, shippingcost;

public:

package()

{
sender="";

receipt="";

costperounce=weight=0.0;

package(int we,int pi,string sen,string rec)

weight=we;

costperounce=pi;

sender=sen;

receipt=rec;

void getvalues(package p[],int n)

for(int i=0;i<n;i++)

cout<<"Enter Package "<<i+1<<" Details::"<<endl;

cin.ignore();

cout<<"Enter Sender Name::";

getline(cin,p[i].sender);

cout<<"Enter Receipt Name::";

getline(cin,p[i].receipt);

lab:

cout<<"Enter Weight ::";

cin>>p[i].weight;

if(p[i].weight<=0)

cout<<"Invalid Input! "<<endl;


goto lab;

label:

cout<<"Enter Cost per Ounce ::";

cin>>p[i].costperounce;

if(p[i].costperounce<=0)

cout<<"Invalid Input! "<<endl;

goto label;

p[i].calculateShippingCost();

void calculateShippingCost()

shippingcost=weight*costperounce;

void show()

cout<<"\n DATA OF PACKAGE :: "<<endl;

cout<<"\n--------------------SHIPPING DETAILS--------------------\n";

cout<<"\n Name of sender::"<<sender;

cout<<"\n Name of receptionist::"<<receipt;

cout<<"\n Weight of package::"<<weight;

cout<<"\n Price Per Ounce::"<<costperounce;

cout<<"\n Total Bill:: "<<shippingcost<<endl;

cout<<"-------------------- THANKS FOR SHIPPING--------------------\n";

}
void display(package p[],int n)

for(int i=0;i<n;i++)

cout<<"\n DATA OF PACKAGE :: "<<i<<endl;

cout<<"\n--------------------SHIPPING DETAILS--------------------\n";

cout<<" Sender Name :: "<<p[i].sender<<endl;

cout<<" Receipt Name :: "<<p[i].receipt<<endl;

cout<<" Weight of Package :: "<<p[i].weight<<endl;

cout<<" Costperounce :: "<<p[i].costperounce<<endl;

cout<<" TOTAL BILL :: "<<p[i].shippingcost<<endl<<endl;

cout<<"-------------------- THANKS FOR SHIPPING--------------------\n";

void set();

};

void package:: set()

cin.ignore();

cout<<"\n Enter Sender Name::";

getline(cin,sender);

cout<<"\n Enter Receipt Name::";

getline(cin,receipt);

lab:

cout<<"\n Enter Weight::";

cin>>weight;

if(weight<0)
goto lab;

lb:

cout<<"\n Enter Cost per Ounce::";

cin>>costperounce;

if(costperounce<0)

goto lb;

int main()

int n;

cout<<"\t\t---------Welcome---------"<<endl;

cout<<"---------------------"<<endl;

cout<<" PLACE YOUR ORDER "<<endl;

cout<<"---------------------"<<endl;

a: cout<<"Enter 1 to ORDER a Single Package Or Enter 2 to ORDER Multiple Package ::";

cin>>n;

if(n==1)

package p;

p.set();

p.calculateShippingCost();

p.show();

else if(n==2)

cout<<"\n Enter Number of Packages::";

cin>>n;

package pa[n];
pa[0].getvalues(pa,n);

pa[0].display(pa,n);

else

cout<<"Invalid Input!"<<endl;

goto a;

return 0;

You might also like