We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Looking For Something at vustudents.ning.com? Click Here to Search

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More


Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

How to Add New Discussion in Study Group ? Step By Step Guide Click Here.


Instructions:

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 dev-C++ 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:

 

  • Create a class named Trapezoid which contains two bases and height as data members.
  • Implement a default constructor to initialize all data members with zero and a parameterized constructor which takes three arguments to initialize data members of class.
  • Take input from user for base1, base2 and height of 2 objects.
  • Overload + operator for the class Trapezoid in such a way that corresponding elements of both objects of the same class can be added.
  • Also implement a friend function named calculateArea() which takes two objects of the class Trapezoid as arguments, adds both objects using overloaded + operator and calculates the area of resultant Trapezoid object.

 

 

 

 

 

Sample output:

             

+ 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?


See Your Saved Posts Timeline

Views: 3712

.

+ 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)

Attachments:

Replies to This Discussion

Solution:

#include <iostream.h>

class Location
{
int l1;
int l2;

public:
Location();
Location(int lon,int lat);
void view();
Location operator ++();
Location operator --();
void* operator new (size_t size);
void operator delete( void * ptr );
};

Location::Location()
{
l1=0;
l2=0;
}

Location::Location(int lon,int lat)
{
l1=lon;
l2=lat;
}
void Location::view()
{
coutendl"Longitude : "l1endl;
cout"Latitude : "l2endlendl;
}
void* Location::operator new(size_t size)
{
cout"Overloaded new operator called....." endl;
void * rtn = malloc (size ) ;
return rtn;
}
Location Location::operator ++()
{
++l1;
++l2;
}
Location Location::operator --()
{
--l1;
--l2;
}
void Location :: operator delete( void *memory )
{
cout"Overload delete operator called....."endlendl;
free( memory );
}

main()
{

system("cls");
Location l1(10,20), *l2= new Location(30,40);

coutendl"Coordinates for Location 1:";
l1.view();
++l1;
cout"After applying overloaded ++ operator on Location 1 : ";
l1.view();
cout"Coordinates for Location 2:";
l2[0].view();
--l2[0];
cout"After applying overloaded -- operator on Location 2 : ";
l2[0].view();
delete l2;
system("pause");
}

ye to compile hi nhi ho rhi is me to err hai jnab

ye compile hona b nahi hai.. q k ye relevent asnwer hai he nahi..

itx nt my solution

teel the correct program

ye solution C++ mai kis tara likaingai

ye file c++ mai kis tara hoga convert ka tarika batai

Suspense ended! 

Tell to your Friends..

Enjoy!

Attachments:

thnks koi error nehi is main

Solution uploaded...

thanks

error hain is main b

RSS

Latest Activity

M_Asim left a comment for Aisha RD
35 seconds ago
Amjad Abbas posted a status
"thanks"
3 minutes ago
Profile IconAmjad Abbas, Nimra zahid, Aisha RD and 31 more joined Virtual University of Pakistan
5 minutes ago
+ Danial replied to +¢αяєℓєѕѕ gιяℓ's discussion Shadi Ho Rhi Hai Alhamdulillah.......... (^__^)!
6 minutes ago
+ Danial liked +¢αяєℓєѕѕ gιяℓ's discussion Shadi Ho Rhi Hai Alhamdulillah.......... (^__^)!
7 minutes ago
+ Iuuoɔǝut + posted videos
14 minutes ago
MUDASAR SHAKIL posted a status
"Mujhe Suspend kyon kar diya jata ha chat se yar"
17 minutes ago
ϝ ι ყ α replied to + "αяsαℓ " Ќąƶµяɨ •"'s discussion Happy Marriage to "Zee" & " Nomi weds Noor"....!
38 minutes ago
Aiman posted a status
"Hello students I am new please tell me their is any student of Bs Psychology I have a problem to make Isl201 assignment please help me"
41 minutes ago
Scorpio liked +¢αяєℓєѕѕ gιяℓ's discussion Shadi Ho Rhi Hai Alhamdulillah.......... (^__^)!
43 minutes ago
Sidra Mustafa replied to + M.Tariq Malik's discussion MGT610 Business Ethics GDB Fall 2019 Solution & Discussion in the group MGT610 Business Ethics
59 minutes ago
Sidra Mustafa joined + M.Tariq Malik's group
59 minutes ago
Imran Khan replied to + M.Tariq Malik's discussion MTH601 Assignment No 01 Fall 2019 Solution & Discussion in the group MTH601 Operations Research
1 hour ago
Profile IconImran Khan, Hashim and Aakash Ahmed joined + M.Tariq Malik's group
1 hour ago
+ ! ! ! ! Mehαr Mαh꧂ replied to + M.Tariq Malik's discussion MGT201 Financial Management GDB Fall 2019 Solution & Discussion Last Date: 22-11-2019 in the group MGT201 Financial Management
1 hour ago
+ ! ! ! ! Mehαr Mαh꧂ liked + M.Tariq Malik's discussion MGT201 Financial Management GDB Fall 2019 Solution & Discussion Last Date: 22-11-2019
1 hour ago
+"Khwab Zaadi"+ liked + M.Tariq Malik's discussion MTH501 Assignment No 01 Fall 2019 Solution & Discussion Due Date: 19-11-2019
1 hour ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to + M.Tariq Malik's discussion MGT201 Financial Management GDB Fall 2019 Solution & Discussion Last Date: 22-11-2019 in the group MGT201 Financial Management
1 hour ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to + M.Tariq Malik's discussion MGT201 Financial Management GDB Fall 2019 Solution & Discussion Last Date: 22-11-2019 in the group MGT201 Financial Management
1 hour ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to + M.Tariq Malik's discussion MGT201 Financial Management GDB Fall 2019 Solution & Discussion Last Date: 22-11-2019 in the group MGT201 Financial Management
1 hour ago

Today Top Members 

© 2019   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service