CS201P Assignment 3 Solution Fall 2021
If you are searching for CS201P Assignment 3 solution for fall 2021, then you are landed on right place.
Requirement for Assignment :
Dev C++ installed in your machine. If not then download it from here.
Must have knowledge of OOP in C++.
Handouts => Download
Past Papers => Download
Practice Quiz => Attempt
Code for CS201 3rd Assignment Solution.
#include <iostream> using namespace std; class Hexagon{ private: int single_side; public: Hexagon(); float calcArea(); float calcPeri(); int calcAngleSum(); void display(); }; Hexagon::Hexagon(){ single_side = 3; } float Hexagon::calcArea(){ return ((1.5 * 1.732) * (single_side * single_side)); } float Hexagon::calcPeri(){ return (6 * single_side); } int Hexagon::calcAngleSum(){ return ( 6 * 120); } void Hexagon::display(){ cout<<endl<<"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 single_side; public: Square(); float calcArea(); float calcPeri(); void display(); }; Square::Square(){ single_side = 3 + 1; } float Square::calcArea(){ return (single_side * single_side); } float Square::calcPeri(){ return (4 * single_side); } void Square::display(){ cout<<endl<<"Area of Square is : "<<calcArea()<<endl; cout<<"Perimeter of Square is : "<<calcPeri()<<endl; } int main(){ Hexagon h; Square s; int choice = 0; bool check = true; do{ 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; switch(choice){ case 1: h.display(); cout<<endl; break; case 2: s.display(); cout<<endl; break; default: check = false; exit(1); } }while(check); return 0; }
Note before coping solution:
This is only just an idea solution you must have to include your own logic into this for 100% marks. You can take it just like a framework for CS201 Assignment 3 Solution.
I think, that you are not right. I can prove it. Write to me in PM.
http://2002.allorgdownload.org/