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




Assignment 2 of CS201 is continuity of assignment 1. You have to do the same task as you did in assignment 1 but this time you have to use structure variables. You have to write C++ program in which; 

• You are required to define 2 structures named as Rectangle and Trapezoid.
• Rectangle has 3 data members, width, length and area
• Trapezoid has 4 data members named as height, base1, base2 and area.
• Provide 2 options to the user as below:
 Enter 1 to calculate the area of Rectangle
 Enter 2 to calculate the area of a Trapezoid

• If the user enters 1, then 
 Object (variable) of Rectangle structure is created
 The program should ask the user to enter the width and length of the rectangle
 Assign input values to data members of Rectangle Structure
 Then show the result after calculation. Formula for calculating Area of rectangle is 
Area = width x Length.

• If the user enters 2, then 
 Object (variable) of Trapezoid structure is created
 The program should ask the user to enter the base1, base2, and height of the trapezoid
 Assign input values to data members of Trapezoid structure 
 Then shows the result after calculation. Formula for calculating Area of trapezoid is 
Area = 
• You must implement two different functions for calculating areas of rectangle and trapezoid.
• After taking the choice from the user in form of 1 or 2 and assigning entered values to respective structure data members, the relevant function should be called to calculate area.
• Function for calculating area should return a value that would be stored in data member of structure to store respective area.
• After storing area, it should be displayed on screen.
• After showing the output to the user, you need to ask the user if he/she wants to do another calculation. If the user presses y or Y, then the program should ask the user again to enter the choice of shape otherwise the program should be terminated.

Screenshot of the program execution is given below for both shapes:

+ 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: 2673

.

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

Replies to This Discussion

Please Discuss here about this assignment.Thanks

Our main purpose here discussion not just Solution

We are here with you hands in hands to facilitate your learning and do not appreciate the idea of copying or replicating solutions.

solution

Attachments:

function define nahi karna tha kia assignment main

IS THIS SOLUTION IS CORRECT ?????

#include <iostream>
using namespace std;

struct Rectangle
{
float width,length,area;

float rectangleArea(float ,float)
{
area=width*length;
return area;
}
};
struct Trapezoid
{
float height,base1,base2,area;

float trapezoidArea(float ,float, float)
{
area=((base1+base2)/2)*height;
return area;
}
};

int main()
{
char repeat;
int choice;
do
{
cout"\n\nPress 1 to calculate the area of Rectangle"endl;
cout"Press 2 to calculate the area of Trapezoid\n"endl;
cout"Enter your choice: ";
cin>>choice;
if(choice==1)
{
Rectangle object;
cout"\nEnter the width of rectangle: ";
cin>>object.width;
cout"Enter the length of rectangle: ";
cin>>object.length;
object.rectangleArea(object.width , object.length);
cout"The Area of Rectangle is: "object.area;
}
else if(choice==2)
{
Trapezoid object;
cout"\nEnter the base1 of trapezoid: ";
cin>>object.base1;
cout"Enter the base2 of trapezoid: ";
cin>>object.base2;
cout"Enter the height of trapezoid: ";
cin>>object.height;
object.trapezoidArea(object.base1 , object.base2 , object.height);
cout"The Area of Trapezoid is: "object.area;
}
else
{
cout"Invalid Choice."endl;
}
cout"\n\nDo you want to do another calculation? (y/n): ";
cin>>repeat;
}
while (repeat=='y'||repeat=='Y');
system("pause");
}

Nhn, function structure k andar nhn define krna,

Thanks Dear

CS201 assignment2 Correct solution, remove my comments add your's, change variable names

Attachments:
Kia structure or function dono use hn gay or structure ko jab initialize kartain hain tu dot (.) ka use hota hai ap nay tu nahi kia Amir bhai

Assignment men to ase he kaha gya he,

dot operator data member ko access krne k lye use hota he chah estructure ho ya class

thnk u so much

welcome

#include
using namespace std;
double AreaofRectangle ();
double AreaofTrapezoid ();
double rectangleArea(double w,double l){
double rectArea;
rectArea = w* 1;
return rectArea;
}
double trapezoidArea(double b1,double b2,double h){
double trapeArea;
trapeArea + ((b1/b2)/2)*h;
return trapeArea;
}
int main(){
int choice1;
char choice2;
double width,length,rectArea,base1,base2,height,trapeArea;
do{
cout"\n\nEnter 1 to calculate the area of Rectangle"endl;
cout"Enter 2 to calculate the area of trapezoid\n\n";
cout"Enter your choice : ";
cin>>choice1;
if(choice1==1){
cout"Enter the width of rectangle : ";
cin>>width;
cout"Enter the length of rectangle : ";
cin>>length;
rectArea = rectangleArea(width,length);
cout"The Area of Rectangle is : "rectAreaendl;
}
else if (choice1==2){
cout"Enter base1 of trapezoid : ";
cin>>base1;
cout"Enter base2 of trapezoid : ";
cin>>base2;
cout"Enter the height of trapezoid : ";
cin>>height;
trapeArea = trapezoidArea(base1,base2,height);
cout"The Area of trapezoid is : "trapeAreaendl;
}
else{
cout"Wrong Input";
}
cout"\nDo you want to do another calculation? : ";
cin>>choice2;
}while(choice2=='y' || choice2=='Y');
system("pause");
}

RSS

Latest Activity

shah G... updated their profile
7 minutes ago
shah G... replied to + M.Tariq Malik's discussion CS401 Assignment No 01 Fall 2019 Solution & Discussion in the group CS401 Computer Architecture and Assembly Language Programming
10 minutes ago
Profile Iconshah G... and Hiba Sani joined + M.Tariq Malik's group
10 minutes ago
yasir MSCS 2nd sem replied to + M.Tariq Malik's discussion CS301 Assignment No 01 Fall 2019 Solution & Discussion in the group CS301 Data Structures
12 minutes ago
Profile Iconyasir MSCS 2nd sem, MUHAMMAD USMAN and Muhammad Aamir joined + M.Tariq Malik's group
12 minutes ago
muddasir replied to + M.Tariq Malik's discussion MGT611 Assignment No 01 Fall 2019 Solution & Discussion Due Date: 14-11-2019 in the group MGT611 Business & Labor Law
14 minutes ago
muddasir joined + M.Tariq Malik's group
14 minutes ago
Muhammad Affan Muneer replied to + M.Tariq Malik's discussion MGT101 Assignment No 01 Fall 2019 Solution & Discussion Due Date: 13-11-2019 in the group MGT101 Financial Accounting
22 minutes ago
Profile IconMuhammad Affan Muneer and Siddiq khan kakar joined + M.Tariq Malik's group
22 minutes ago
Mumtaz Hussain liked + M.Tariq Malik's discussion CS101 Assignment No 01 Fall 2019 Solution & Discussion
26 minutes ago
+ ! ! ! ! ᎠixieᎠuຮt꧂ liked Usman Mughal's discussion Fall 2019 Assignment No. 1 English Comprehension (Eng101)
27 minutes ago
muddasir and Adil Iqbal are now friends
29 minutes ago
Mohsin pervaiz liked Usman Mughal's discussion Fall 2019 Assignment No. 1 English Comprehension (Eng101)
31 minutes ago
Profile IconNaeem jani and abdul ghafoor joined + M.Tariq Malik's group
37 minutes ago
Profile IconNabeel Ahmed, M IDREES and Abdul Ghaffar joined + M.Tariq Malik's group
55 minutes ago
BILAL Maher replied to + M.Tariq Malik's discussion CS401 Assignment No 01 Fall 2019 Solution & Discussion in the group CS401 Computer Architecture and Assembly Language Programming
1 hour ago
+¢αяєℓєѕѕ gιяℓ replied to Moji's discussion Assignment #1 Semester FALL 2019 Physics (PHY101)
2 hours ago
Asmat replied to + "J ɨ y ą ⋆'s discussion CS501 Assignment No 01 Fall 2019 Solution & Discussion Due Date: 12-11-2019 in the group CS501 Advance Computer Architecture
2 hours ago
+!!! NOOR UL JANAT !!!+ replied to Rana Ali's discussion Alfaz
2 hours ago
Rana Ali replied to Rana Ali's discussion Alfaz
3 hours ago

Today Top Members 

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

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