السلام عليكم :
انا لسه مبتدأ في c# واجهتني مشكله فقلت ان شاء الله تحلولي اياها :
بدي اعمل برنامج كالتالي ( اسف ان كان بالانجليزي ولكن لانه مصطلجات علميه فلا يهم ) :
Write an application that inputs from the user the radius of a circle and prints the circle`s diameter ,circumference and area . Use the following formulas :(r is radius ):
( في اشاره الpi او ط في العربي مو عارف اكتبها فبكتبها على شكل 22/7 وانتوا تصرفوا :D )
diameter = 2*r
circumference = 2*22/7*r
area = 22/7*r*r
كتبت الكود كما اعرف وهيه :
using System;
namespace ConsoleApplication14
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
string radius;
int diameter,
circumference,
area;
Console.Write ( " Please Enter The Radius of Your Circle : " );
radius = Console.ReadLine ();
diameter = Int32.Parse (radius);
circumference = Int32.Parse (radius);
area = Int32.Parse (radius );
diameter = 2 * radius;
circumference = (2) * (22/7)*(radius);
area = (22/7) * (radius * radius);
Console.WriteLine (" The diameter is {0}.", diameter);
Console.WriteLine ( " The circumference is {0}.", circumference);
Console.WriteLine ( " The area is {0}.", area );
}
}
}وكان عندي الخطأ انه :
The Operator * cannot be applied to operands of type "int" and "string".
شو العمل ؟؟؟
بانتظار الاجابه؟؟؟؟