Exemple #1
0
    public static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());
        int c = int.Parse(Console.ReadLine());
        int d = int.Parse(Console.ReadLine());

        if (b > c && d > a && c + d > a + b && c > 0 && d > 0 && a % 2 == 0)
        {
            Cosnole.WriteLine("Valores aceitos");
        }
        else
        {
            Console.WriteLine("Valores nao aceitos");
        }
    }
Exemple #2
0
    public static void Main()
    {
        int a = 4;
        int b = 5;
        int c = -1;

        if (b * b - 4 * a * c >= 0)
        {
            Cosnole.WriteLine("Równanie kwadratowe ma rozwiązanie w zbiorze liczb rzeczywistych");
        }
        else
        {
            Console.WriteLine("Równanie kwadratowe nie ma rozwiązań w zbiorze liczb rzeczywistych");
        }
        Console.ReadKey();
    }
Exemple #3
0
        public void ShowDetails(EquipModel em)
        {
            Cosnole.WriteLine("Serial Number:");
            Console.WriteLine(em.serialNumber);

            Cosnole.WriteLine("Inputs:");
            Console.WriteLine(em.inputs.ToString());

            Cosnole.WriteLine("Outputs:");
            Console.WriteLine(em.uotputs.ToString());

            Cosnole.WriteLine("Type:");
            Console.WriteLine(em.type);

            Cosnole.WriteLine("Model:");
            Console.WriteLine(em.model);
        }
Exemple #4
0
        static void Main(string[] args)
        {
            #region Variables
            // ************* Variables *************** //

            //Create a variable of type int called id. Initialize it to 75.
            int id = 75;
            //Create a variable of type string called name. Initialize it to your full name.
            string name = "Dylan Abeyta";
            //Create a variable of type bool called isValid. Initialize it to true.
            bool isValid = true;
            //Create a variable of type int called userID. Don't initialize this value. (In C#, ints default to 0)
            int userID;
            //Create a variable of type string called state. Don't initialize this value. (In C#, strings default to null)
            string state;
            //Create a variable of type bool called hasRan. Don't initialize this value. (In C#, booleans default to false)
            bool hasRan;
            //Create a variable of type char called myCharacter. Initialize this value to "a".
            char myCharacter = 'a';
            //Create a variable of type double called myDouble. Initialize this value to 3.14
            double myDouble = 3.14;
            //Create a variable of type float called myFloat. Initialize this value to 3.14 (cannot convert double to float, check 1.0 slides)
            float myFloat = 3.14f;
            //Create a variable of type Random called rand. Initialize it to a new Random Object.
            Random rand = new Random();

            #endregion
            #region Conditionals
            // ************ Conditionals ************* //

            //Create a variable of type bool called isValid. Initialize it to true.
            bool isValid = true;
            //if isValid is true, then console writeline "isValid is true"
            if (isValid == true)
            {
                Console.WriteLine("isValid is True");
            }
            //else if isValid is not true, then console writeline "isValid is not true"
            else if (isValid != true)
            {
                Console.WriteLine("isValid is not true");
            }


            //Create a variable of type int called x. Initialize it to 75.
            int x = 75;
            //Create a variable of type int called y. Initialize it to 100.
            int y = 100;
            //If x is greater than y, then console writeline "X is Greater than Y"
            if (x > y)
            {
                Console.WriteLine("x is greater than y");
            }
            //else if x is equal to y, then console writeline "X is equal to Y"
            else if (x == y)
            {
                Console.WriteLine("x is equal to y");
            }
            //else, then console writeline "X is less than Y"
            else
            {
                Cosnole.WriteLine("x is less than y");
            }
            ;
            //Create a variable of type string called country. Initialize it to "Mexico".
            string country = "Mexico";
            //Create a variable of type int called age. Initialize it to 18.
            int age = 18;
            //If country is "Mexico" and age is greater than or equal to 18 then console writeline "You can legally drive"
            if (country == "Mexico" && age >= 18)
            {
                Console.WriteLine("you can legally drive");
            }
            //else if country is not "Mexico" and age is greater than or equal to 16 then console writeline "You can legally drive"
            else if (country != "Mexico" && age >= 16)
            {
                Console.WriteLine("you can legally drive");
            }
            //else console writeline "you cannot legally drive"
            else
            {
                Console.WriteLine("you cannot legally drive");
            }


            #endregion
            #region Loops
            // **************** Loops **************** //

            //for loop starting at i = 0 and continue while i < 10, incrementing by 1. Console writeline the value of i each time.
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(i);
            }
            //for loop starting at i = 0 and continue while i < 30, incrementing by 2. Console writeline the value of i each time.
            for (int i = 0; i < 30; i += 2)
            {
                Console.WriteLine(i);
            }
            //for loop starting at i = 30 and continue while i >= 0, decrementing by 1. Console writeline the value of i each time.
            for (int i = 30; i >= 0; i--)
            {
                Console.WriteLine(i);
            }
            //for loop starting at i = 30 and continue while i > 0, decrementing by 3. Console writeline the value of i each time.
            for (int i = 30; i > 0; i -= 3)
            {
                Console.WriteLine(i);
            }
            //Create an int variable called index, initialize it to 0.
            int index = 0;
            //while index < 10 Console writeline index.
            while (index < 10)
            {
                Console.WriteLine(index);
                index++;
            }
            //reset index variable to 0
            int index = 0;
            //while index < 0 console writeline index
            while (index < 0)
            {
                Console.WriteLine(index);
                index++;
            }
            //Reset index variable to 0
            int index = 0;
            //do-while index < 10 console writeline index.
            do
            {
                Console.WriteLine(index);
                index++;
            } while (index < 10);
            //reset index variable to 0
            int index = 0;
            //do-while index < 0 console writeline index
            do
            {
                Console.WriteLine(index);
                index++;
            } while (index < 0);
            //Create an int variable called input, initialize to 0
            int input = 0;
            //Accept user input with Console.ReadLine and parse it into an integer with int.Parse. Store in input variable.
            input = int.Parse(Console.ReadLine());
            //do-while input does not equal -1, console writeline "Input -1 to end program, input any other number to continue"
            do
            {
                Console.WriteLine("input -1 to end program, input any other nuumber to continue");
            } while (input != -1);
            #endregion
            #region Arrays
            // *************** Arrays **************** //

            //Create an array of type int and of size 10 called intArray. Don't initialize any data. (Remember, ints default to 0 so you now have an array of 10 0's.)
            int[] intArray = new int[10];
            //Create an array of type string and of size 5 called stringArray. Don't initialize any data.
            string[] stringArray = new string[5];
            //For the following, change each index individually. Do not use a loop or assignment on declaration
            intArray[0] = 0;
            intArray[1] = 1;
            intArray[2] = 2;
            intArray[3] = 3;
            intArray[4] = 4;
            intArray[5] = 5;
            intArray[6] = 6;
            intArray[7] = 7;
            intArray[8] = 8;
            intArray[9] = 9;

            //Populate intArray with data following the formula: data = index * 3. IE the 3rd element of intArray will equal 9.
            intArray[0] *= 3;
            intArray[1] *= 3;
            intArray[2] *= 3;
            intArray[3] *= 3;
            intArray[4] *= 3;
            intArray[5] *= 3;
            intArray[6] *= 3;
            intArray[7] *= 3;
            intArray[8] *= 3;
            intArray[9] *= 3;

            //Populate stringArray with the following data: firstName, lastName, city, state, country
            stringArray[0] = "firstName";
            stringArray[1] = "lastName";
            stringArray[2] = "City";
            stringArray[3] = "state";
            stringArray[4] = "Country";

            //for the following use a loop to assign the data into the arrays.

            //set each index data of intArray using the following formula: data = index * 2 + 1. IE the 3rd element will equal 7
            for (int i = 0; i < 10; i++)
            {
                intArray[i] = i * 2 + 1;
            }
            //set each index data of stringArray to "The current index is i" where i is the actual value of i

            for (int i = 0; i < 5; i++)
            {
                stringArray[i] = ("the current is " + i);
            }
            //reset intArray to be a new int array of size 5. In the same line (hint, use { }) set the values to 0,1,2,3,4.
            int[] intArray = new intArray[5] {
                0, 1, 2, 3, 4
            };
            //reset stringArray to be a new string array of size 3. In the same line (hint, use { }) set the values to "buddy", "guy", "Friend"
            string[] stringArray = new stringArray[3] {
                "buddy", "guy", "Friend"
            };
            //for int i = 0, continue for the length of intArray, and increment i + 1, console writeline the value of intArray
            for (int i = 0; i < intArray.Length; i++)
            {
                Console.WriteLine(intArray[i]);
            }
            //for int i = 0, continue for the length of stringArray, and increment i + 1, console writeline the value of stringArray
            for (int i = 0; stringArray.Length; i++)
            {
                Console.WriteLine(stringArray[i]);
            }
            //iterate over (AKA use a for loop) intArray similarly to what you did above, but do it backwards. Print the last index first, and the 0th index last.
            for (int i = intArray.Length; i > 0; i--)
            {
                Console.WriteLine(intArray[i]);
            }
            //iterate over (AKA use a for loop) stringArray similarly to what you did above, but do it backwards. Print the last index first, and the 0th index last.
            for (int i = stringArray.Length; i > 0; i--)
            {
                Console.WriteLine(stringArray[i]);
            }
            #endregion
        }
 public static void Main()
 {
     Cosnole.WriteLine("Hello,world!");
 }