CS304 Assignment 1 Solution
#1
Here is the solution for CS304 Asignment 1 spring 2016

Please do not copy. Its for understanding purpose only, you can ask me if you have any questions.
Code:
#include <iostream>
#include <string>
using namespace std;

class Parcel
{
    private:
        int Id;
        string SenderName;
        string SenderAddress;
        string receiverName;
        string receiverAddress;
        int Weight;
        int Fee;
    public:
        //Default Constructor
        Parcel(){
            Id = 0;
            Weight = 0;
            Fee = 0;
        }
        
        //Destructor
        ~Parcel(){
        }
        
        //Setters
        void setId(int x){
            
            Id = x;
        }
        void setSenderName(char* name1){
            SenderName = name1;
        }
        void setSenderAddress(char* add1){
            SenderAddress = add1;
        }
        void setReceiverName(char* name2){
            receiverName = name2;
        }
        void setReceiverAddress(char* add2){
            receiverAddress = add2;
        }
        void setWeight(int w){
            Weight = w;
        }
        void setFee(int f){
            Fee = f;
        }
        
        //Getters
        int getId(){
            return Id;
        }
        string getSenderName(){
            return SenderName;
        }
        string getSenderAdd(){
            return SenderAddress;
        }
        string getReceiverName(){
            return receiverName;
        }
        string getReceiverAdd(){
            return receiverAddress;
        }
        int getWeight(){
            return Weight;
        }
        int getFee(){
            return Fee;
        }
        
        
};

int main()
{
    int id, fee, weight;
    char senderName[50];
    char senderAdd[100];
    char receiverName[50];
    char receiverAdd[100];
    
    Parcel parcel1;
    
    //Getting values from user and saving in the class using Setters
    
    cout<<" Enter receipt No. : ";
    cin>> id;
    parcel1.setId(id);
    cout<<endl;
    
    cout<<" Enter Sender Name : ";
    cin.ignore();
    cin.getline(senderName, sizeof(senderName));
    parcel1.setSenderName(senderName);
    cout<<endl;
    
    cout<<" Enter Sender Address : ";
    cin.getline(senderAdd, sizeof(senderAdd));
    parcel1.setSenderAddress(senderAdd);
    cout<<endl;
    
    cout<<" Enter Receiver Name : ";
    cin.getline(receiverName, sizeof(receiverName));
    parcel1.setReceiverName(receiverName);
    cout<<endl;
    
    cout<<" Enter Receiver Address : ";
    cin.getline(receiverAdd, sizeof(receiverAdd));
    parcel1.setReceiverAddress(receiverAdd);
    cout<<endl;
    
    cout<<" Enter weight(in grams) of the parcel : ";
    cin>> weight;
    parcel1.setWeight(weight);
    cout<<endl;
    
    cout<<" Enter shipment charges : ";
    cin>> fee;
    parcel1.setFee(fee);
    cout<<endl;
    cout<<endl;
    
    //Displaying info using Getters
    cout << "Shipment Receipt";
    cout << "\n---------------------------";
    cout << "\n Receipt No. : " << parcel1.getId();
    cout << "\n Sender Name : " << parcel1.getSenderName();
    cout << "\n Sender Address : " << parcel1.getSenderAdd();
    cout << "\n Receiver Name : " << parcel1.getReceiverName();
    cout << "\n Receiver Address : " << parcel1.getReceiverAdd();
    cout << "\n Parcel Weight (in grams) : " << parcel1.getWeight();
    cout << "\n Shipment Charges : " << parcel1.getFee();

    return 0;

}
#2
(05-17-2016, 03:09 PM)Rana Wrote: Here is the solution for CS304 Asignment 1 spring 2016

Please do not copy. Try to understand and then make yours, if you have any question, you can ask in the comments. 
Code:
#include <iostream>
#include <string>
using namespace std;

class Parcel
{
    private:
        int Id;
        string SenderName;
        string SenderAddress;
        string receiverName;
        string receiverAddress;
        int Weight;
        int Fee;
    public:
        //Default Constructor
        Parcel(){
            Id = 0;
            Weight = 0;
            Fee = 0;
        }
        
        //Destructor
        ~Parcel(){
        }
        
        //Setters
        void setId(int x){
            
            Id = x;
        }
        void setSenderName(char* name1){
            SenderName = name1;
        }
        void setSenderAddress(char* add1){
            SenderAddress = add1;
        }
        void setReceiverName(char* name2){
            receiverName = name2;
        }
        void setReceiverAddress(char* add2){
            receiverAddress = add2;
        }
        void setWeight(int w){
            Weight = w;
        }
        void setFee(int f){
            Fee = f;
        }
        
        //Getters
        int getId(){
            return Id;
        }
        string getSenderName(){
            return SenderName;
        }
        string getSenderAdd(){
            return SenderAddress;
        }
        string getReceiverName(){
            return receiverName;
        }
        string getReceiverAdd(){
            return receiverAddress;
        }
        int getWeight(){
            return Weight;
        }
        int getFee(){
            return Fee;
        }
        
        
};

int main()
{
    int id, fee, weight;
    char senderName[50];
    char senderAdd[100];
    char receiverName[50];
    char receiverAdd[100];
    
    Parcel parcel1;
    
    //Getting values from user and saving in the class using Setters
    
    cout<<" Enter receipt No. : ";
    cin>> id;
    parcel1.setId(id);
    cout<<endl;
    
    cout<<" Enter Sender Name : ";
    cin.ignore();
    cin.getline(senderName, sizeof(senderName));
    parcel1.setSenderName(senderName);
    cout<<endl;
    
    cout<<" Enter Sender Address : ";
    cin.getline(senderAdd, sizeof(senderAdd));
    parcel1.setSenderAddress(senderAdd);
    cout<<endl;
    
    cout<<" Enter Receiver Name : ";
    cin.getline(receiverName, sizeof(receiverName));
    parcel1.setReceiverName(receiverName);
    cout<<endl;
    
    cout<<" Enter Receiver Address : ";
    cin.getline(receiverAdd, sizeof(receiverAdd));
    parcel1.setReceiverAddress(receiverAdd);
    cout<<endl;
    
    cout<<" Enter weight(in grams) of the parcel : ";
    cin>> weight;
    parcel1.setWeight(weight);
    cout<<endl;
    
    cout<<" Enter shipment charges : ";
    cin>> fee;
    parcel1.setFee(fee);
    cout<<endl;
    cout<<endl;
    
    //Displaying info using Getters
    cout << "Shipment Receipt";
    cout << "\n---------------------------";
    cout << "\n Receipt No. : " << parcel1.getId();
    cout << "\n Sender Name : " << parcel1.getSenderName();
    cout << "\n Sender Address : " << parcel1.getSenderAdd();
    cout << "\n Receiver Name : " << parcel1.getReceiverName();
    cout << "\n Receiver Address : " << parcel1.getReceiverAdd();
    cout << "\n Parcel Weight (in grams) : " << parcel1.getWeight();
    cout << "\n Shipment Charges : " << parcel1.getFee();

    return 0;

}
#3
hmmmmmmmmmmmmmmmm welldone
#4
(05-20-2016, 12:02 AM)Waryam Choudhry Wrote: hmmmmmmmmmmmmmmmm welldone

Thank you.
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  CS601 Data Communication Assignment Solution Rana 0 520 11-26-2016, 03:27 PM
Last Post: Rana
Lightbulb Need CS502 Assignment no 1 solution Adorable Pakhtoon 3 249 11-17-2016, 04:21 PM
Last Post: Rubaisha(Moody Girl)
  CS502 assignment 1 Solution 2016 Rubaisha(Moody Girl) 0 702 11-17-2016, 04:18 PM
Last Post: Rubaisha(Moody Girl)
  CS602 assignment solution idea 2016 Rubaisha(Moody Girl) 0 250 11-16-2016, 10:49 AM
Last Post: Rubaisha(Moody Girl)
  MGT101 assignment solution 2016 Rubaisha(Moody Girl) 0 245 11-16-2016, 10:39 AM
Last Post: Rubaisha(Moody Girl)
  CS401 assignment 1 solution of question 1 Rubaisha(Moody Girl) 0 68 11-16-2016, 10:36 AM
Last Post: Rubaisha(Moody Girl)
  CS614 complete solution of assignment 1 2016 Rubaisha(Moody Girl) 0 239 11-16-2016, 10:22 AM
Last Post: Rubaisha(Moody Girl)
  CS302 Assignment Solution Rana 8 755 11-15-2016, 05:28 PM
Last Post: Rana
  CS304 Assignment 1 Solution - Fall 2016 Rana 1 522 11-10-2016, 08:45 AM
Last Post: Lahori
  Cs610 assignment solution Rubaisha(Moody Girl) 0 174 11-07-2016, 08:22 PM
Last Post: Rubaisha(Moody Girl)



Users browsing this thread:
1 Guest(s)