اذهب إلى المحتوى
  • 0

سؤال للبرمجه

رهف الجهني

السؤال

اكتبي برنامج على الدوال التالية:

- التحويل من درجة المئوية (celsius)الى فهرنهايت(fahrenheit)

توقيع الدالة (pubic double  celsius ToFfahrenheit(double celsius

- التحويل من فهرنهايت (fahrenheit)الى درجة مئوية (celsius)

توقيع الدالة(pubic double fahrenheit ToCelsius (double  fahrenheit

التحويلات المستخدمة في التحويل:

   fahrenheit=(9.0/5)*  celsius+32

(celsius=(5.0/9 )*fahrenheit_32

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

  • 0

أهلًا بك،

هكذا يكون الكود من سيليزيوس لفهرنهايت

using System;
					
public class Program
{
    public double fahrenheit;

    public double celsiusToFahrenheit(double celsius)
    {
        fahrenheit=(9.0/5)*  celsius+32;
        return fahrenheit;
    }

    public static void Main(string[] args)
    {

        Console.WriteLine("Please enter the celsius you wish to convert");
        var   celsius = double.Parse(Console.ReadLine()); // Creating new variable

        Program p = new Program();

        p.celsiusToFahrenheit(celsius); // Pass parameter to our function

        Console.WriteLine("fahrenheit result " + p.fahrenheit + "Degrees "); 
    }
}

من فهرنهايت لسليزيوس

using System;
					
public class Program
{
    public double celsius;

    public double fahrenheitToCelsius(double fahrenheit)
    {
        celsius=(5.0/9 )*fahrenheit-32;
        return celsius;
    }

    public static void Main(string[] args)
    {

        Console.WriteLine("Please enter the fahrenheit you wish to convert");
        var   fahrenheit = double.Parse(Console.ReadLine()); // Creating new variable

        Program p = new Program();

        p.fahrenheitToCelsius(fahrenheit); // Pass parameter to our function

        Console.WriteLine("celsius result " + p.celsius + "Degrees "); 
    }
}

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0
x = 0
while x == 0:
    Tall = int(input("Enter a number to convert it >>>    "))
    opt = int(input("Enter 1 to convert from meter to foot... \n or 2 to convert from foot to meter... "))
    if opt == 1:
      in_Foot = Tall * 0.3048
      print("{} meter = {} foot".format(Tall, in_Foot))
      x = 1
    elif opt == 2:
      in_Meter = Tall * 3.2808399
      print("{} foot = {} meter".format(Tall, in_Meter))
      x = 1
    else :
      print( "you entered a wrong value please enter 1 or 2")
      x = 0

 

rewrt.py

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...