Advertisement
Guest User

Car-Program #DanikirDeGever

a guest
May 29th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication16
  8. {
  9. class Program
  10. {
  11. static Car[] input(Car[] c)
  12. {
  13. int MaxSpeed, price;
  14. for (int i = 0; i < c.Length; i++)
  15. {
  16. Console.WriteLine("Enter Max Speed and Price for Car " + (i + 1));
  17. MaxSpeed = int.Parse(Console.ReadLine());
  18. price = int.Parse(Console.ReadLine());
  19. c[i] = new Car(MaxSpeed, price, "Black", 4, "Mazda", true);
  20. }
  21. return c;
  22. }
  23. static void Print(Car[] c)
  24. {
  25. int max = 0, min = 999999999, temp = 0;
  26. for (int i = 0; i < c.Length; i++)
  27. {
  28. if (c[i].GetMaxSpeed() > max)
  29. {
  30. if (c[i].GetPrice() < min)
  31. {
  32. max = c[i].GetMaxSpeed();
  33. min = c[i].GetPrice();
  34. temp = i;
  35. }
  36. }
  37. }
  38. Console.WriteLine("The Car Who costs minimal and drive the fastest is:\n" + c[temp].ToString());
  39. }
  40. public static void Main(string[] args)
  41. {
  42. Car[] c = new Car[3];
  43. c = input(c);
  44. Print(c);
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement