Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication16
- {
- class Program
- {
- static Car[] input(Car[] c)
- {
- int MaxSpeed, price;
- for (int i = 0; i < c.Length; i++)
- {
- Console.WriteLine("Enter Max Speed and Price for Car " + (i + 1));
- MaxSpeed = int.Parse(Console.ReadLine());
- price = int.Parse(Console.ReadLine());
- c[i] = new Car(MaxSpeed, price, "Black", 4, "Mazda", true);
- }
- return c;
- }
- static void Print(Car[] c)
- {
- int max = 0, min = 999999999, temp = 0;
- for (int i = 0; i < c.Length; i++)
- {
- if (c[i].GetMaxSpeed() > max)
- {
- if (c[i].GetPrice() < min)
- {
- max = c[i].GetMaxSpeed();
- min = c[i].GetPrice();
- temp = i;
- }
- }
- }
- Console.WriteLine("The Car Who costs minimal and drive the fastest is:\n" + c[temp].ToString());
- }
- public static void Main(string[] args)
- {
- Car[] c = new Car[3];
- c = input(c);
- Print(c);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement