CS201 Assignment No 3 Solution Spring 2018 | Virtual Study Solutions

Adsetra Ads

 

CS201 Assignment No 3 Spring 2018

Dear Students, Here you can read or Download CS201Introduction to Programming Assignment No 3 Solution of Semester Spring 2018. Assignment Due Date is 26 July, 2018. Total Marks are 20. We are here to facilitate your learning and we do not appreciate the idea of copying or replicating solutions. CS201 Assignment Solution File has been added. Previously we shared CS201 Final Term Past Papers Solved by Waqar Siddhu.

CS201 assignment No 3 Solution Spring 2019  Download 


CS201 Assignment No 3 Solution and Disccusion Spring 2018
CS201 Assignment No 3 Solution and Disccusion Spring 2018

CS201 Assignment Instructions

Please read the following instructions carefully before submitting assignment:
It should be clear that your assignment will not get any credit if:

  • Assignment is submitted after due date. 
  • Submitted assignment does not open or file is corrupt. 
  • Assignment is copied (From internet/ from other students). 

CS201 Assignment allowed Software 

  • Dev C++ 
Recommended: DevC++ Installation and Usage Complete Guidelines

CS201 Assignment Objectives:

Student will be able to analyze and implement the concepts of:
  • Classes and Objects 
  • Constructors in classes 
  • Getter and Setter functions in classes 

CS201 Assignment Submission Instructions

You have to submit only .cpp file on the Assignments interface of CS201 at VULMS. Assignment submitted in any other format will not be accepted and will be graded zero marks.

CS201 Assignment Question

Write a C++ program that will create a class named Laptop.

This class will have 4 data members

  • brand 
  • processor 
  • ram 
  • hardDrive 
Also write getter and setter functions for each data member of the class. For example:

void setbrand(char[]);
void setCpu(char[]);
…………….etc

intgetRam();
intgetHD();
………………… etc

You are required to write a default and a parameterized constructor for this class.

In the default constructor, you will initialize all the data members with default values. The message “Default constructor called…” should be displayed whenever an object is created using default constructor.

In parameterized constructor, you will initialize all the data members with the values passed to it as arguments. You are required to use setter functions inside parameterized constructor to initialize the data members. The message “Parameterized constructor called…” should be displayed whenever an object is created with parameterized constructor.

In main() function, create 2 objects (1 using default and 1 using parameterized constructor) and display the values of data members of both objects using getter functions. 

CS201 Assignment Sample Output

Sample output for the program is shown below:

CS201 Assignment No 3 Sample Output
CS201 Assignment No 3 Sample Output
Please Note:
You must use setter functions inside the parameterized constructor for initialization of the data members with the values passed by arguments. Also you have to use getter functions in the main() to show the values of data members. Marks will be deducted if any of these requirements is not fulfilled

CS201 Assignment No 3 Solution Spring 2018

You can see the Sample Preview of Assignment No 3 Solution provided by (Virtual Study Solutions) below. Click on Download Button to Download Solution File in Your PC. Please Share it with your friends. You can also like our Facebook Page or Subscribe Us below for Updates.

CS201 Assignment Solution Code Sample Preview

CS201 Solution File Sample Page Preview has been added below with Solution File in word file and .cpp file.

Solution Code Preview:

#include <iostream>
#include <string>
using namespace std;
class Laptop
{
    private:
        string Brand, Processor;
        int Ram, hardDrive;

    public:
    Laptop()
        {
            cout<<"Default Constructor Called \n";
            Brand = "None";
            Processor = "None";
            Ram = 0;
            hardDrive = 0;
        }

        void setBrand(string b)
        { Brand = b; }
        void setProcessor(string p)
        { Processor = p; }
        void setRam(int r)
        { Ram = r; }
        void sethD(int hd)
        { hardDrive = hd; }

        string getBrand()
        { return Brand; }
        string getProcessor()
        { return Processor; }
        int getRam()
        { return Ram; }
        int gethD()
        { return hardDrive; }

    Laptop(string theBrand, string theProcessor, int theRam, int thehardDrive)
        { 
          cout<<"Parameterized Constructor Called...\n";
          Brand = theBrand;
          Processor = theProcessor;
          Ram =  theRam;
          hardDrive = thehardDrive;
        }
    };

/* Solution code by www.virtualstudysolutions.blogspot.com */

int main()
{

  Laptop l;
  cout<<"\nBrand : "<<l.getBrand()<<"\nProcessor : "<<l.getProcessor()<<"\nRam : "<<l.getRam()<<"\nHard Drive : "<<l.gethD()<<"\n\n";


  Laptop l2("dell", "i5", 4, 500);
  cout<<"\nBrand : "<<l2.getBrand()<<"\nProcessor : "<<l2.getProcessor()<<"\nRam : "<<l2.getRam()<<"\nHard Drive : "<<l2.gethD()<<"\n";
  system("pause");
}

Test Code Output with C++ Online Compiler:

CS201 Assignment Solution Code has been tested using Online C++ Compiler you can see the Live output Preview of code by clicking the test code button below:



Output Screenshot:
CS201 Assignment Solution Code Sample Output via Online C++ Compiler
CS201 Assignment Solution Code Sample Output via Online C++ Compiler
Previous Assignments of Spring 2018:


CS201 Assignment No 3 Solution Download Link

Download  [ .Docx File Upload Status : Done ]

Download  [ .Cpp File Upload Status : Done ]

Post a Comment

 

Top