www.vustudents.ning.com

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

# CS304 Assignment #2 Solution

Dear students please discuss here about the solution of CS304 ( Object Oriented Programming ) assignment #2.

Views: 10844

Attachments:

### Replies to This Discussion

cs 304 assigment solution 2016

check this pl

Attachments:

Cs 304 assignment solution

Attachments:

SK Sir apki awaz itniiiiiiiiiiiiii slow

ap microphone use kr lia krn na meny headphones he use kiye thy

IDEA SOLUTION ATTACHED

Attachments:

### CS304 Assigment # 02

#include <iostream>
#include <string>
using namespace std;
class Parcel{
protected: // changed from private to protected
int Id;
string senderName;
int weight;
int fee;
public:
Parcel(){
Id = 0;
senderName = "";
weight = 0;
fee = 0;
}
void setId(int id){
Id = id;
}
int getId(){
return Id;
}

void setSenderName(string sname){
senderName = sname;
}
string getSenderName(){
return senderName;
}

}
}

}
}

}
}

void setWeight(int w){
weight = w;
}
int getWeight(){
return weight;
}

void setFee(int f){
fee = f;
}
int getFee(){
return fee;
}

};
class normalParcel: public Parcel{
protected:
int chargesPerGram;
int basicCharges;
string shipmentType = "Normal";
public:
void setChargePerGram(int charges){
chargesPerGram = charges;
}
int getChargesPerGram(){
return chargesPerGram;
}
void setBasicCharges(int charges){
basicCharges = charges;
}
int getBasicCharges(){
return basicCharges;
}
string getShipmentType(){
return shipmentType;
}
};
class urgentParcel: public Parcel{
protected:
int chargesPerGram;
int basicCharges;
string shipmentType = "Urgent";
public:
void setChargePerGram(int charges){
chargesPerGram = charges;
}
int getChargesPerGram(){
return chargesPerGram;
}
void setBasicCharges(int charges){
basicCharges = charges;
}
int getBasicCharges(){
return basicCharges;
}
string getShipmentType(){
return shipmentType;
}
}
}
};
int main(int argc, char** argv) {
cout"Assignment solution cs304 by Blu ( fb.com/92blu )"endlendl;
int selection;
while(1){
cout"Enter 1 for normal and 2 for urgent services.\n\nSelect type of service: ";
cin>>selection;
if(selection==1){
int id, weight, charges, fee, overWeightCharges;
cout"Normal service selected.\n";
normalParcel p;
cout"Enter receipt number: ";
cin>>id;
p.setId(id);
cout"Enter sender name: ";
cin>>senderName;
p.setSenderName(senderName);
cout"Enter weight of parcel in grams: ";
cin>>weight;
p.setWeight(weight);
cout"Enter basic charges for the parcel: ";
cin>>charges;
p.setBasicCharges(charges);
cout"Enter fee per gram: ";
cin>>fee;
p.setFee(fee);
cout"\n\n\nShipment Receipt\n-------------------\n";
cout"Receipt No: "p.getId()endl;
cout"Sender Name: "p.getSenderName()endl;
cout"Parcel Weight: "p.getWeight()endl;
if(p.getWeight()>900){
overWeight = "Yes";
} else {
overWeight = "No";
}
cout"Over Weight: "overWeightendl;
cout"Basic Charges: "p.getBasicCharges()endl;
if(overWeight=="Yes"){
overWeightCharges = (p.getWeight() - 900) * p.getFee();
} else {
overWeightCharges = 0;
}
cout"Over Weight Charges: "overWeightChargesendl;
cout"Shipment Total Charges: "p.getBasicCharges() + overWeightChargesendl;
cout"Shipment type: "p.getShipmentType()endl;
return 0;
} else if(selection==2){
int id, weight, charges, fee, overWeightCharges, additionalfee;
cout"Urgent service selected.\n";
urgentParcel p;
cout"Enter receipt number: ";
cin>>id;
p.setId(id);
cout"Enter sender name: ";
cin>>senderName;
p.setSenderName(senderName);
cout"Enter weight of parcel in grams: ";
cin>>weight;
p.setWeight(weight);
cout"Enter basic charges for the parcel: ";
cin>>charges;
p.setBasicCharges(charges);
cout"Enter fee per gram: ";
cin>>fee;
p.setFee(fee);
cout"Enter additional fee par gram: ";
cout"\n\n\nShipment Receipt\n-------------------\n";
cout"Receipt No: "p.getId()endl;
cout"Sender Name: "p.getSenderName()endl;
cout"Parcel Weight: "p.getWeight()endl;
if(p.getWeight()>900){
overWeight = "Yes";
} else {
overWeight = "No";
}
cout"Over Weight: "overWeight"g"endl;
cout"Basic Charges: "p.getBasicCharges()+(p.getBasicCharges()/2)endl;
if(overWeight=="Yes"){
overWeightCharges = (p.getWeight() - 900) * (p.getFee()+p.getAdditionalFee());
} else {
overWeightCharges = 0;
}
cout"Over Weight Charges: "overWeightChargesendl;
cout"Shipment Total Charges: "p.getBasicCharges() + (p.getBasicCharges()/2) + overWeightChargesendl;
cout"Shipment type: "p.getShipmentType()endl;
return 0;
} else {
cout"Selected type of service is incorrect.\n\n";
}
}
return 0;
}

@dear Mr. Sk or what ever, excuse me plz . I have read all of your comments and I felt bad to see your attitude. It is a helping platform students come here to give or take help. so if you want to help the students be patient and if you dont have patience then be quite and dont reply . I STRONGLY CONDEMN that the student should copy the metrial they sholud discuss it but all the people dont have the same mind words or situations so they act according to it. I hope u understand as u look genius enough thanks

Agreed.

great you have much knowledge I admit cheers

I am not taking it on me I have said in comment that I strongly condemn copying  I just asking u to be patient like a teacher cuz you are trying to be a teacher it looks me :)

@SK esay log khud yahan se copy kar ke upload kartay hain. app ne notice kia ke MSc 3rd Semester hai or es discussion p lecture de rahe hai. abhi do while ka sytax puch lo to 30 min internet p search karain ge. phir kahin se copy kar ke dekha dein ge. or VU ne bohat acha step lia hai video presentation wala. kam se kam en jesay jahil kam ho jain ge.

mr Muhammad sarmad apni language daikhen jahil tu ap apni language se lag rhy ho by the way kia qualification hy apki and kiya job hy btana chahen gy mj jasi jahil ko ?????

You are still a student. or baat karnay se pahlay soch lia karain kis se kar rahe hain. kam se kam seniority level ke he respect kar lain.

1

2

3

4

5

## VIP Member Badge & Others

------------------------------------