Your cousins Jimmy and Jenna (JJ) and studying geometry in school and need some help understanding the relationship between geometric shapes. You’ve offered to help with your newfound C# skills. Write a program that implements programmer defined methods for the following geometric functions – use double variables for all your calculations. a. Compute the area of a circle – method should have one parameter, the radius, and return the area b. Compute the circumference of a circle – method should have one parameter, the radius, and return the circumference c. Compute the area of a square – method should have one parameter, length of a side, and return the area d. Compute the perimeter of a square – method should have one parameter, length of a side, and return the perimeter e. Compute the area of a triangle – method should have two parameters, the base and height, and return the area Your program should use FIVE programmer‐defined methods (one for each of the calculations). Each method should have parameters and return the desired calculation. Your program should ask for values in Main(), call the procedures, and then output the returned value in Main().
Code
class GeometryShape
{
static void Main(string[] args)
{
string userChoice;
while(true)
{
menu();
userChoice = Console.ReadLine();
Console.WriteLine();
if (userChoice == "a" || userChoice == "b")
{
double radius;
Console.Write("Enter the radius of the circle: ");
radius = Convert.ToDouble(Console.ReadLine());
if (userChoice == "a")
{
Console.WriteLine("Area of the circle :" +
calculateCircleArea(radius));
}
else
{
Console.WriteLine("Circumference of the circle :" +
calculateCirclecircumference(radius));
}
}
else if (userChoice == "c" || userChoice == "d")
{
double length;
Console.Write("Enter the length of the square: ");
length = Convert.ToDouble(Console.ReadLine());
if (userChoice == "c")
{
Console.WriteLine("Area of the square :" +
calculateSquareArea(length));
}
else
{
Console.WriteLine("Perimeter of the square :" +
calculateSquareperimeter(length));
}
}
else if (userChoice == "e")
{
double b, h;
Console.Write("Enter base of the triangle: ");
b = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter height of the triangle: ");
h = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Area of the triangle :" +
calculateTriangleArea(b, h));
}
else if (userChoice == "q")
break;
else
Console.WriteLine("Invalid choice!");
Console.WriteLine();
}
}
private static double calculateTriangleArea(double b, double
h)
{
return (b * h) / 2;
}
private static double calculateSquareperimeter(double
length)
{
return 4 * (length);
}
private static double calculateSquareArea(double length)
{
return length * length;
}
private static double calculateCirclecircumference(double
radius)
{
return 2 * Math.PI * radius;
}
private static double calculateCircleArea(double radius)
{
return Math.PI * radius*radius;
}
private static void menu()
{
Console.WriteLine("a. Compute the area of a circle");
Console.WriteLine("b. Compute the circumference of a
circle");
Console.WriteLine("c. Compute the area of a square");
Console.WriteLine("d. Compute the perimeter of a square");
Console.WriteLine("e. Compute the area of a triangle");
Console.WriteLine("q. Quit");
Console.Write("Enter you choice: ");
}
}
output


If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.
Your cousins Jimmy and Jenna (JJ) and studying geometry in school and need some help understanding...
Using Python Write the following well-documented (commented) program. Create a class called Shape that has a method for printing the area and the perimeter. Create three classes (Square, Rectangle, and Circle) which inherit from it. Square will have one instance variable for the length. Rectangle will have two instance variables for the width and height. Circle will have one instance variable for the radius. The three classes will have methods for computing the area and perimeter of its corresponding shape....
You will be creating a driver class and 5 class files for this assignment. The classes are Shape2D (the parent class), Circle, Triangle, and Rectangle (all children of Shape2D) and Square (child of Rectangle). Be sure to include a message to the user explaining the purpose of the program before any other printing to the screen. Within the driver class, please complete the following tasks: Instantiate a Circle object with 1 side and a radius of 4; print it Update...
JAVA Code Requried Copy the file java included below. This program will compile, but, when you run it, it doesn’t appear to do anything except wait. That is because it is waiting for user input, but the user doesn’t have the menu to choose from yet. We will need to create this. Below the main method, but in the Geometry class, create a static method called printMenu that has no parameter list and does not return a value. It will...
Java... Write a class that has three overloaded static methods for calculating the areas of the following geometric shapes: • circles -- area = π*radius^2 (format the answer to have two decimal places) • rectangles -- area = width * length • trapezoid -- area = (base1 + base2) * height/2 Because the three methods are to be overloaded, they should each have the same name, but different parameters (for example, the method to be used with circles should only...
C++ programming question will upvote
A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following int main //the radius of the...
Implement the Shape hierarchy -- create an abstract class called Shape, which will be the parent class to TwoDimensionalShape and ThreeDimensionalShape. The classes Circle, Square, and Triangle should inherit from TwoDimensionalShape, while Sphere, Cube, and Tetrahedron should inherit from ThreeDimensionalShape. Each TwoDimensionalShape should have the methods getArea() and getPerimeter(), which calculate the area and perimeter of the shape, respectively. Every ThreeDimensionalShape should have the methods getArea() and getVolume(), which respectively calculate the surface area and volume of the shape. Every...
Please show all work and answer all parts using python,
thanks!
Instructions You will need to create four files: • Shape2D.py - file containing a class definition containing properties all Shapes could possibly have. • Circle.py - file containing a class definition of a Circle that inherits from the Shape2D class. Square.py - file containing a class definition of a Square that inherits from the Shape2D class. • testFile.py - file containing pytest functions testing the Shape2D, Circle, and Square...
Need some help on this C++ program. Circle - color:String - radius:double +Circle() +Circle(newColor:String, newRadius:double) +setColor(color:String):void +setRadius(radius:double):void +getColor():String +getRadius():double +printCircleInfo():void Create the class using three files - a .h, a .cpp and a main.cpp Create a class called Circle as describe below Constructor with no arguments Sets radius to 1 and color to “black” Constructor with arguments Sets the color and radius to the values passed in Get methods (accessors) return the field that the get refers to Set methods...
A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following: int main() { double radius; double area; double circumference; //the radius...
Creating a Class in C++ Summary In this lab, you create a programmer-defined class and then use it in a C++ program. The program should create two Rectangle objects and find their area and perimeter. Instructions Ensure the class file named Rectangle.cpp is open in your editor. In the Rectangle class, create two private attributes named length and width. Bothlength and width should be data type double. Write public set methods to set the values for lengthand width. Write public...