CS201 Assignment 3 Spring 2021 – Assignments – Solution VU
Please read the following instructions carefully before submitting assignment:
It should be clear that your assignment will not get any credit if:
o Assignment is submitted after due date.
o Submitted assignment does not open or file is corrupt.
o Assignment is copied (From internet/students).
Recommended tool to develop Assignment
– Dev C++
To enable students to understand and practice the concepts of:
- Classes and its structure.
- Data Members and Member functions of the class.
- Constructor of the class.
Assignment Submission Instructions
You have to submit only.cpp file on the assignments interface of CS201 from your LMS account. Assignment submitted in any other format will not be accepted and will be scaled with zero marks.
For any query related to assignment, please contact [email protected].
Suppose an XYZ company hires you as a C++ developer and assigns you the task of developing a scientific calculator (program) for the user. The program has to be developed in such a way that it should display the following menu to the user.
Ø For option ‘1’ the program should set the radius of the circle, calculate its area, circumference and display it on the screen.
Ø For option ‘2’ the program should set the width and height of the rectangle, calculate its area and display it on screen.
Ø For any option other than 1, and 2 the program should display invalid output.
Ø After performing any of the above operations the program should also ask the user if he/she wants to carry out the same operation again.
To achieve the above task you first need to create three separate classes Circle and Rectangle. The description of each class should be as follows:
Circle class will have ‘radius’ as its data member and setRadius(), computeAreaCirc() as its member functions. The setRadius() function will set the value of its data member ‘radius’ in the main function. The computeAreaCirc() member function will compute and display the area and circumference of the circle class.
Rectangle class will have ‘height’, ‘width’ as its data members and setLength(), setWidth() and computeArea() as its member functions. The setLength(), setWidth() will set the value of its data member ‘height’ and ‘width’ in the main function. The computeArea() function will compute and display area of the rectangle class.
You also need to create constructor of each class which will initialize its data members with default values.
For consistency of the assignment, source data of the class data members should be set as follows:
RADIUS = 5.6
LENGTH = 5.0
WIDTH = 4.0
Note: Marks will be deducted if the source data of the class is varied from the above data.
Sample Screenshot of Output:
If the user selects option ‘1’.
If the user selects option ‘2’
If the user selects any other option.
After completing the calculations the program should prompt the user to perform the calculation again Y/N:
If the user does not want to perform any calculation. The program should terminate successfully.
#CS201 #Assignment #Spring #Assignments #Query