CS201P Assignment 3 Solution Virtual University (100%) || Introduction to Programming Practical

preview_player
Показать описание
CS201P Assignment 3 Solution Virtual University (100%) || Introduction to Programming PracticalCS201P Assignment 3 Solution Virtual University (100%) || Introduction to Programming PracticalCS201P Assignment 3 Solution Virtual University (100%) || Introduction to Programming PracticalCS201P Assignment 3 Solution Virtual University (100%) || Introduction to Programming PracticalCS201P Assignment 3 Solution Virtual University (100%) || Introduction to Programming Practical
#CS201P #assignment3 #VU #practical
Рекомендации по теме
Комментарии
Автор

#include<iostream>
using namespace std;

// developed by Sheraz Aslam
class Hexagon
{private:
int s;
public:
void input(int side){
s = side;
}
float calcArea(){
return 1.5*1.732*s*s;
}
int calcPeri(){
return 6*s;
}

int calcAngleSum(){
int a=120;
return 6*a;
}
void display()
{
cout<<"Area of Hexagon is:"<<calcArea()<<endl;
cout<<"Perimeter of Hexagon is:"<<calcPeri()<<endl;
cout<<"Sum of angles of Hexagon is:"<<calcAngleSum()<<endl;
}
};

class Square
{
private:
int s;
public:
void input(int side){
s = side;
}
int calcAreaSquare(){
return s*s;
}
int calcPeriSquare(){
return 4*s;
}
void display(){
cout<<"Area of Square
cout<<"Perimeter of Square
}
};



int main(){
Hexagon hex;
Square sq;
int choice;
int vuID =4;
int sideHex = vuID;
int sideSq = vuID+1;
bool check=true;
while(check)
{
cout<<"Enter 1 to Calculate area, perimeter and sum of angels of hexagon:"<<endl;
cout<<"Enter 2 to Calculate area and perimeter of square"<<endl;
cout<<"Press any other key to exit"<<endl;
cin>>choice;
if(choice==1)
{
hex.input(sideHex);
hex.display();
}
else if(choice==2){
sq.input(sideSq);
sq.display();
}
else{
check=false;
}
}
return 0;
}
#include<iostream>
using namespace std;

// developed by KAinat Mustafa
class Hexagon
{private:
int s;
public:
void input(int side){
s = side;
}
float calcArea(){
return 1.5*1.732*s*s;
}
int calcPeri(){
return 6*s;
}

int calcAngleSum(){
int a=120;
return 6*a;
}
void display()
{
cout<<"Area of Hexagon is:"<<calcArea()<<endl;
cout<<"Perimeter of Hexagon is:"<<calcPeri()<<endl;
cout<<"Sum of angles of Hexagon is:"<<calcAngleSum()<<endl;
}
};

class Square
{
private:
int s;
public:
void input(int side){
s = side;
}
int calcAreaSquare(){
return s*s;
}
int calcPeriSquare(){
return 4*s;
}
void display(){
cout<<"Area of Square
cout<<"Perimeter of Square
}
};



int main(){
Hexagon hex;
Square sq;
int choice;
int vuID =4;
int sideHex = vuID;
int sideSq = vuID+1;
bool check=true;
while(check)
{
cout<<"Enter 1 to Calculate area, perimeter and sum of angels of hexagon:"<<endl;
cout<<"Enter 2 to Calculate area and perimeter of square"<<endl;
cout<<"Press any other key to exit"<<endl;
cin>>choice;
if(choice==1)
{
hex.input(sideHex);
hex.display();
}
else if(choice==2){
sq.input(sideSq);
sq.display();
}
else{
check=false;
}
}
return 0;
}

Dr.SherazAslam
visit shbcf.ru