We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>
+ Link For Assignments, GDBs & Online Quizzes Solution 
+ Link For Past Papers, Solved MCQs, Short Notes & More 


Please read the following instructions carefully before submitting assignment. It should be clear that your assignment will not get any credit if:
§ The assignment is submitted after due date. § The submitted assignment does not open or file is corrupt. § Assignment is copied(partial or full) from any source (websites, forums, students, etc)
Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted and will be awarded with zero marks. For example, if you submit code in .doc (Word document) or .txt files, no reward will be given in any case.
Objective:
The objective of this assignment is to provide hands on experience of:
§ Objects and Classes § Constructors and Destructors in classes § Setters and Getters in classes § Use of friend functions § Operator overloading
Guidelines:
§ Code should be properly indented and well commented. § Follow C/C++ rules while writing variable names, function names etc § Use only devC++ for this assignment.


Assignment 

Problem Statement: You are required to write a program for calculating area of Trapezoid. Formula for calculating area of trapezoid is
Where a and b are two bases of trapezoid and h corresponds to height.
Detailed Description:
Sample output:

Tags:
+ How to Follow the New Added Discussions at Your Mail Address?
+ How to Join Subject Study Groups & Get Helping Material? + How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators? + VU Students Reserves The Right to Delete Your Profile, If?.
+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)
+ Click Here to Search (Looking For something at vustudents.ning.com?) + Click Here To Join (Our facebook study Group)Aliza ap ne error kesay theek kia?
CS201 Assignment # 4 ; Due date 28 Jan 2013
Complete Working Solution..
Please change the some variable names...
file compile nahi ho rahi dost
Complete Solution.......
//////////////////////////Assignment NO .4 ///////////////////////////////////
#include <iostream>
#include <stdlib.h>
#include <conio.h>
using namespace std;
class Trapezoid{
public:
Trapezoid();
Trapezoid(float,float,float);
Trapezoid operator +(Trapezoid&);
void GetInput();
void SetBase1(float);
void SetBase2(float);
void SetHeight(float);
void display();
friend void CalculateArea(Trapezoid,Trapezoid);
private:
float base1,base2,height;
};
Trapezoid::Trapezoid()
{
base1 = 0.0;
base2 = 0.0;
height = 0;
}
Trapezoid::Trapezoid(float b1,float b2,float h)
{
base1 = b1;
base2 = b2;
height = h;
}
void Trapezoid::display()
{
coutendl;
cout"After adding both objects by using overloaded + operator\n"endl;
cout"Base 1 = " base1endl;
cout"Base 2 = " base2endl;
cout"Height = " heightendl;
coutendl;
cout"Area of Trapezoid : "(base1+base2)/2*height;
}
void Trapezoid::SetBase1(float b1)
{
base1 = b1;
}
void Trapezoid::SetBase2(float b2)
{
base2 = b2;
}
void Trapezoid::SetHeight(float h)
{
height = h;
}
Trapezoid Trapezoid :: operator + (Trapezoid & trap)
{
Trapezoid temp;
temp.base1 = base1 + trap.base1;
temp.base2 = base2 + trap.base2;
temp.height = height + trap.height;
return temp;
}
void Trapezoid::GetInput()
{
float b1 = 0.0;
float b2 = 0.0;
float h = 0;
coutendl;
cout"Enter Base 1:";
cin>>b1;
cout"Enter Base 2:";
cin>>b2;
cout"Enter Height:";
cin>>h;
SetBase1(b1);
SetBase2(b2);
SetHeight(h);
}
void CalculateArea(Trapezoid b1,Trapezoid b2)
{
Trapezoid temp;
temp = b1 + b2;
temp.display();
}
int main()
{
Trapezoid b1;
Trapezoid b2;
coutendl;
cout"Enter Data for Object 1 :\n";
b1.GetInput();
cout"Enter Data for Object 2 :\n";
b2.GetInput();
CalculateArea(b1,b2);
getch();
}
100% ok solution
#include <iostream>
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
using namespace std;
class trapezoid{
public:
trapezoid();
trapezoid(float,float,float);
trapezoid operator +(trapezoid&);
void getinput();
void set_base1(float);
void set_base2(float);
void set_hight(float);
void display();
friend void calculateArea(trapezoid,trapezoid);
private:
float base1,base2,hight;
};
trapezoid::trapezoid()
{
base1 = 0.0;
base2 = 0.0;
hight = 0;
}
trapezoid::trapezoid(float bs1,float bs2,float ht)
{
base1 = bs1;
base2 = bs2;
hight = ht;
}
void trapezoid::display()
{
cout"base 1: "base1endl;
cout"base 2: "base2endl;
cout"hight : "hightendl;
cout"The Eare of the Trapezoid is: "(base1+base2)/2*hightendl;
}
void trapezoid::set_base1(float bs1)
{
base1 = bs1;
}
void trapezoid::set_base2(float bs2)
{
base2 = bs2;
}
void trapezoid::set_hight(float ht)
{
hight = ht;
}
trapezoid trapezoid::operator+(trapezoid& trap)
{
trapezoid temp;
temp.base1 = base1 + trap.base1;
temp.base2 = base2 + trap.base2;
temp.hight = hight + trap.hight;
return temp;
}
void trapezoid::getinput()
{
float bs1 = 0.0;
float bs2 = 0.0;
float ht = 0;
cout"Please Enter Base 1: ";
cin>>bs1;
cout"Please Enter Base 2: ";
cin>>bs2;
cout"Please Enter Hight: ";
cin>>ht;
set_base1(bs1);
set_base2(bs2);
set_hight(ht);
}
void calculateArea(trapezoid bs1,trapezoid bs2)
{
trapezoid temp;
temp = bs1 + bs2;
temp.display();
}
int main()
{
trapezoid bs1;
trapezoid bs2;
cout"Object {1}"endl;
bs1.getinput();
coutendl;
cout"Object {2}"endl;
bs2.getinput();
calculateArea(bs1,bs2);
_getch();
}
100% ok solution
cout"base 1: "base1endl;
is line ma q error aa raha hy..??? :/
koi error ni hai. Thanks tariq bhai
Jazaak ALLAH
Hello! Friends, anybody solved the CS201 Assignment 4 at his own?
I would like to understand full assignment step by step, if anybody could do, this will be a great help and i will appreciate that, thx in advance
© 2019 Created by + M.Tariq Malik. Powered by
Promote Us  Report an Issue  Privacy Policy  Terms of Service
VU Students reserves the right to delete any profile, which does not show any Activity at site nor has not any activity more than 01 month.
We are usergenerated contents site. All product, videos, pictures & others contents on vustudents.ning.com don't seem to be beneath our Copyrights & belong to their respected owners & freely available on public domains. We believe in Our Policy & do according to them. If Any content is offensive in your Copyrights then please email at m.tariqmalik@gmail.com or Contact us at contact Page with copyright detail & We will happy to remove it immediately.
Management: Admins ::: Moderators
Awards Badges List  Moderators Group
All Members  Featured Members  Top Reputation Members  Angels Members  Intellectual Members  Criteria for Selection
Become a Team Member  Safety Guidelines for New  Site FAQ & Rules  Safety Matters  Online Safety  Rules For Blog Post