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

نديم يافاوي

الأعضاء
  • المساهمات

    8
  • تاريخ الانضمام

  • تاريخ آخر زيارة

أجوبة بواسطة نديم يافاوي

  1. السلام عليكم
    كيف يمكن كتابة وبرمجة هذا المشروع 
    عفوا اخواني على هذا الكود بسبب دمج اللغتين السويدية والانكليزية لهذا يمكن ان يكون متعب للبعض 
    جزيل الشكر

     

     

    In this task, you will create a class named Bil

    For a Bil object you should be able to specify a årsmodell with a set method and obtain the årsmodell with a get method

    ()The Bil must have its two states " Bilen kör " and " Bilen står stilla ", which one can read with the method status  

    ()Initially, the Bil condition " står stilla " but it changes if you call the method start

    "One can stop the Bil with the stop () method and then of course the status changes to " står stilla

     

    Below I test the class Bil and wrote the following in main

    public static void Main(string[] args)
    {
      Bil fiat = new Bil();
      fiat.setYear(2017);
      Console.WriteLine("Har nu skaffat mig en bil av " + fiat.getYear() + " års modell");
      Console.WriteLine(fiat.status());
      Console.WriteLine("Försöker starta bilen");
      fiat.start();
      Console.WriteLine("Måste kolla om du kom igång... " + fiat.status());
      Console.WriteLine("Försöker få stopp på bilen");
      fiat.stop();
      Console.WriteLine("Ska se om jag lyckades stanna den också... " + fiat.status());
      Console.ReadKey();
    }

     

    The following will appear on the screen:

     

    Har nu skaffat mig en bil av 2017 års modell
    Bilen står stilla
    Försöker starta bilen
    Måste kolla om du kom igång... Bilen kör
    Försöker få stopp på bilen
    Ska se om jag lyckades stanna den också... Bilen står stilla

     

  2. بتاريخ 17 ساعات قال محمد المري2:

    بالإمكان عمله بطريقة ابسط وب loop واحد فقط.  وايضاً انصح بإستخدام switch في حالة تعدد الاختيارات كما هو بسؤالك. سيكون افضل. 

    
    List<int> inputList = new List<int>();
    decimal total = 0.0M;
    int userChoice = 0;
    
    for (int x = 0; x < 10; x++)
    {
      Console.Write("Enter number " + (x + 1) + " :");
      inputList.Add(Convert.ToInt32(Console.ReadLine()));
      total += inputList[x];
    }
    Console.WriteLine();
    Console.WriteLine("Choose what you want to do:");
    Console.WriteLine(" 1. Show the largest number");
    Console.WriteLine(" 2. Show the smallest number");
    Console.WriteLine(" 3. Show the mean to one decimal");
    Console.WriteLine(" 4. Display all input numbers");
    Console.WriteLine(" 5. Finish this program");
    
    userChoice = Convert.ToInt32(Console.ReadLine());
    
    switch (userChoice)
    {
      case 1: // 1. Show the largest number
        Console.WriteLine("Max : \t" + inputList.Max());
        break;
      case 2: // 2. Show the smallest number
        Console.WriteLine("Min : \t" + inputList.Min());
        break;
      case 3: // 3. Show the mean to one decimal
        Console.WriteLine("Mean : \t" + (total / inputList.Count));
        break;
      case 4: // 4. Display all input numbers
        string allNumbers = string.Join(Environment.NewLine, inputList);
        Console.WriteLine(allNumbers);
        break;
      case 5: // 5. Finish this program
        Environment.Exit(0);
        break;
    }
    
    // Keep The console open
    Console.WriteLine();
    Console.WriteLine("Press any key to exit ...");
    Console.ReadLine();

     

    بتاريخ 17 ساعات قال محمد المري2:

    بالإمكان عمله بطريقة ابسط وب loop واحد فقط.  وايضاً انصح بإستخدام switch في حالة تعدد الاختيارات كما هو بسؤالك. سيكون افضل. 

    
    List<int> inputList = new List<int>();
    decimal total = 0.0M;
    int userChoice = 0;
    
    for (int x = 0; x < 10; x++)
    {
      Console.Write("Enter number " + (x + 1) + " :");
      inputList.Add(Convert.ToInt32(Console.ReadLine()));
      total += inputList[x];
    }
    Console.WriteLine();
    Console.WriteLine("Choose what you want to do:");
    Console.WriteLine(" 1. Show the largest number");
    Console.WriteLine(" 2. Show the smallest number");
    Console.WriteLine(" 3. Show the mean to one decimal");
    Console.WriteLine(" 4. Display all input numbers");
    Console.WriteLine(" 5. Finish this program");
    
    userChoice = Convert.ToInt32(Console.ReadLine());
    
    switch (userChoice)
    {
      case 1: // 1. Show the largest number
        Console.WriteLine("Max : \t" + inputList.Max());
        break;
      case 2: // 2. Show the smallest number
        Console.WriteLine("Min : \t" + inputList.Min());
        break;
      case 3: // 3. Show the mean to one decimal
        Console.WriteLine("Mean : \t" + (total / inputList.Count));
        break;
      case 4: // 4. Display all input numbers
        string allNumbers = string.Join(Environment.NewLine, inputList);
        Console.WriteLine(allNumbers);
        break;
      case 5: // 5. Finish this program
        Environment.Exit(0);
        break;
    }
    
    // Keep The console open
    Console.WriteLine();
    Console.WriteLine("Press any key to exit ...");
    Console.ReadLine();

     

     

    جزيل الشكر اخي محمد :)

  3. مرحبا اعزائي المبرمجين

    كيف يمكن كتابة هكذا برنامج؟

    You should create a program where the user can input 10 numbers. The speech should be saved in an array / list and after the input the user should be able to see the largest number or the smallest number or the average or all the numbers. A program run may look like the following:

    Enter number 1: 12
    Enter number 2: 8
    Enter number 3: 34
    Enter number 4: 23
    Enter number 5: 9
    Enter number 6: 62
    Enter number 7: 41
    Enter number 8: 7
    Enter number 9: 14
    Enter number 10: 53

    Choose what you want to do
    1. Show the largest number
    2. Show the smallest number
    3. Show the mean to one decimal
    4. Display all input numbers
    5. Finish this program
     

×
×
  • أضف...