Что такое кодирование, чтобы найти это?
Write an application that computes the area of a circle, rectangle, and cylinder. Display a menu showing the three options. Allow users to input which figure they want to see calculated. Based on the value inputted, prompt for appropriate dimensions and perform the calculations using the following formulas: Area of a circle = pi * radius2 Area of a rectangle = length * width Surface area of a cylinder = 2 * pi * radius * height + 2 * pi * radius2 Write a modularized solution that includes class methods for inputting data and performing calculations.
Что я уже пробовал:
using System; using static System.Console; namespace myShape { class Program { const double PI = 3.14; static void Main(string[] args) { double length, width; string inputValue; double perimeter, area; WriteLine("Please input the length of the rectangel: "); inputValue = ReadLine(); length = double.Parse(inputValue); WriteLine("Please input the width of the rectangel: "); inputValue = ReadLine(); width = double.Parse(inputValue); perimeter = Perimeter(length, width); area = Area(length, width); WriteLine("The perimter of rectangle is {0:F2}", Perimeter(length, width)); WriteLine("The area of rectangle is {0:F4}", area); double radius; WriteLine("Please input the radius of the circle: "); inputValue = ReadLine(); radius = double.Parse(inputValue); WriteLine("The perimter of circle is {0:F2}", Perimeter(radius)); } public static double Perimeter(double length, double width) { double perimeter = 0; perimeter = 2 * (length + width); return perimeter; } public static double Perimeter(double radius) { double perimeter = 0; perimeter = 2*PI*radius; return perimeter; } public static double Area(double length,double width) { return length * width; } } }
Patrice T
В чем проблема с этим кодом ?
t778987
правильно ли это?