static void displayPatient(Patient p)
 {
     Console.Clear();
     TruongHeading.getHeading(APP_NAME);
     Console.WriteLine("  ---------------------------------------");
     Console.WriteLine("  Patient Information");
     Console.WriteLine("  ---------------------------------------");
     Console.WriteLine("  {0, -25}: {1}", "First Name", p.firstName.ToString());
     Console.WriteLine("  {0, -25}: {1}", "Last Name", p.lastName);
     Console.WriteLine("  {0, -25}: {1}", "Age", p.age);
     Console.WriteLine("  {0, -25}: {1}", "Height (inches)", p.heightInInches);
     Console.WriteLine("  {0, -25}: {1}", "Weight (pounds)", p.weightInPounds);
     Console.WriteLine("  ---------------------------------------");
     Console.WriteLine("  Body Mass Index");
     Console.WriteLine("  ---------------------------------------");
     Console.WriteLine("  {0, -25}: {1:0.00}", "BMI", GetBMIValue(p.weightInPounds, p.heightInInches));
     Console.WriteLine(GetBMIName(p.weightInPounds, p.heightInInches));
     Console.WriteLine("  ---------------------------------------");
     Console.WriteLine("  Heart Rate Info");
     Console.WriteLine("  ---------------------------------------");
     Console.WriteLine("  {0, -25}: {1}", "Max Heart Rate", GetMaxinumHeartRate(p.age));
     Console.WriteLine("  {0, -25}: {1}", "Max Target Heart Rate", GetMaxTargetHeartRate(p.age));
     Console.WriteLine("  {0, -25}: {1}", "Min Target Heart Rate", GetMinTargetHeartRate(p.age));
     Console.WriteLine("  Press enter to return to main screen.");
     Console.ReadLine();
 }
        static void Main(string[] args)
        {
            TruongHeading.getHeading("Assignment 9");

            double balance1 = 2000.00, balance2 = 3000.00;

            SavingsAccount saver1 = new SavingsAccount(balance1);
            SavingsAccount saver2 = new SavingsAccount(balance2);

            SavingsAccount.ModifyInterestRate(0.04);

            double monthlyInterestMoney1 = saver1.CalculateMonthlyInterest();
            double monthlyInterestMoney2 = saver2.CalculateMonthlyInterest();

            Console.WriteLine("  Monthly new balance of customer 1 at 4% is: {0:C}",
                              balance1 + monthlyInterestMoney1);
            Console.WriteLine("  Monthly new balance of customer 2 at 4% is: {0:C}",
                              balance2 + monthlyInterestMoney2);
            Console.WriteLine();

            SavingsAccount.ModifyInterestRate(0.05);

            double monthlyInterestMoney3 = saver1.CalculateMonthlyInterest();
            double monthlyInterestMoney4 = saver2.CalculateMonthlyInterest();

            Console.WriteLine("  Monthly new balance of customer 1 at the interest rate 5% is: {0:C}",
                              balance1 + monthlyInterestMoney3);
            Console.WriteLine("  Monthly new balance of customer 2 at the interest rate 5% is: {0:C}",
                              balance2 + monthlyInterestMoney4);
            TruongHeading.getClosing();
            Console.ReadLine();
        }
Beispiel #3
0
    public static void Main(string[] args)
    {
        TruongHeading.getHeading("Assignment 4");
        Sales application = new Sales();

        application.CalculateSales();
        TruongHeading.getClosing();
        Console.Read();
    } // end Main
Beispiel #4
0
 static void Main(string[] args)
 {
     TruongHeading.getHeading("Assignment 2");
     Console.WriteLine("  Exponents and Roots Application\n");
     Console.Write("  Exponents ---------------------|" + "   Roots ------------------------------------|");
     Console.WriteLine("{0,2}{1,4}{2,7}{3,10}  {4,-10}  {5,-7}  {6,-4}  {7,-2}", "  Number", "  Square", "Cube",
                       "  Fifth", "  Fourth", " Seventh", "  Twelfth", "  Fifteenth");
     Console.WriteLine("{0,2} {1,5}{2,7}{3,10}   {4,-10}  {5,-7}  {6,-4}  {7,-2}", "  ------", " ------",
                       " ----", "-----", " ------", "-------", "  -------", "  ---------");
     for (int i = 1; i <= 15; i++)
     {
         Console.WriteLine(String.Format("{0,6}{1,8}{2,9:,0}{3,10:,0}     {4,-11:0.00}{5,-9:0.000}  {6,-10:0.0000} {7,-9:0.00000}",
                                         i, Math.Pow(i, 2.0), Math.Pow(i, 3.0), Math.Pow(i, 5.0), Math.Pow(i, (1.0 / 4.0)), Math.Pow(i, (1.0 / 7.0)),
                                         Math.Pow(i, (1.0 / 12.0)), Math.Pow(i, (1.0 / 15.0))));
     }
     TruongHeading.getClosing();
 }
        static void Main(string[] args)
        {
            TruongHeading.getHeading("Assignment 3");
            Console.WriteLine("  Please enter your first name.");
            Console.SetCursorPosition(2, 7);
            String input1 = Console.ReadLine();

            Console.WriteLine("  Please enter your last name.");
            Console.SetCursorPosition(2, 9);
            String input2 = Console.ReadLine();

            Console.WriteLine("  Please enter your birth year.");
            Console.SetCursorPosition(2, 11);
            int input3 = Convert.ToInt32(Console.ReadLine());

            Console.Clear();
            TruongHeading.getHeading("Assignment 3");
            Console.WriteLine("  ==================================================");
            Console.Write("  The following information was input:\n\n");
            HeartRates hrates = new HeartRates(input1, input2, input3);

            Console.WriteLine(hrates.printOff);
            TruongHeading.getClosing();
        }
        static int displayMainMenu()
        {
            int    choice        = 0;
            bool   invalidChoice = false;
            string inputChoice   = "";

            while (!invalidChoice)
            {
                Console.Clear();
                TruongHeading.getHeading(APP_NAME);
                string menu = Menu();
                Console.WriteLine(menu);
                Console.Write("  Choice: ");
                inputChoice = Console.ReadLine();



                if (!int.TryParse(inputChoice, out choice))
                {
                    Console.WriteLine("  Error!");
                    Console.WriteLine("  - Enter a numeric value only!");
                    Console.WriteLine("  -----------------------------");
                    menu = Menu();
                    Console.WriteLine(menu);
                    Console.Write("  Choice: ");
                    inputChoice = Console.ReadLine();
                }
                else
                {
                    if (choice == 1)
                    {
                        Patient patient = createPatient();
                        patients[validPatientIdx] = patient;
                    }
                    else if (choice == 2)
                    {
                        if (alreadyInput == true)
                        {
                            Console.Clear();
                            TruongHeading.getHeading(APP_NAME);
                            listPatients(patients);
                            Console.WriteLine("\n  Enter a patient number to display a patient's");
                            Console.WriteLine("  info, or type 'q' to return to the main menu");
                            string getInput = Console.ReadLine();
                            int    patientNum;
                            bool   IsPatientNum = Int32.TryParse(getInput, out patientNum);

                            if (getInput == "q")
                            {
                                //continue;
                            }
                            else if (IsPatientNum)
                            {
                                displayPatient(patients[patientNum]);
                            }
                        }
                        else
                        {
                            Console.Clear();
                            TruongHeading.getHeading(APP_NAME);
                            Console.WriteLine("No patients. Press enter to return to the main menu.");
                            Console.ReadLine();
                        }
                    }
                    else if (choice == 3)
                    {
                        System.Environment.Exit(1);
                    }
                    else
                    {
                        Console.WriteLine("  Error! Enter a number from 1 to 3");
                        menu = Menu();
                        Console.WriteLine(menu);
                        Console.Write("  Choice: ");
                        inputChoice = Console.ReadLine();
                    }
                }
            }
            return(choice);
        }
        static Patient createPatient()
        {
            validPatientIdx++;
            Console.Clear();
            TruongHeading.getHeading(APP_NAME);
            Console.Write("  Please enter patient's first name: ");
            String fName = Console.ReadLine();

            Console.Write("  Please enter patient's last name: ");
            String lName = Console.ReadLine();

            Console.Write("  Please enter patient's age: ");
            String age = Console.ReadLine();
            int    ageNum;
            bool   checkAge = false;

            while (!checkAge)
            {
                if (!int.TryParse(age, out ageNum))
                {
                    Console.WriteLine("  Error! Age must be a numeric value only.");
                    Console.Write("  Please enter patient's age: ");
                    age = Console.ReadLine();
                }
                else
                {
                    if (Convert.ToInt32(age) <= 0)
                    {
                        Console.WriteLine("  Error! Age must be a positive number only.");
                        Console.Write("  Please enter patient's age: ");
                        age = Console.ReadLine();
                    }
                    else
                    {
                        checkAge     = true;
                        alreadyInput = true;
                    }
                }
            }
            Console.Write("  Please enter patient's weight in pounds: ");
            String weightInPounds = Console.ReadLine();
            int    weightNum;
            bool   checkWeight = false;

            while (!checkWeight)
            {
                if (!int.TryParse(weightInPounds, out weightNum))
                {
                    Console.WriteLine("  Error! Weight must be a numeric value only.");
                    Console.Write("  Please enter patient's weight: ");
                    weightInPounds = Console.ReadLine();
                }
                else
                {
                    if (Convert.ToInt32(weightInPounds) <= 0)
                    {
                        Console.WriteLine("  Error! Weight must be a positive number only.");
                        Console.Write("  Please enter patient's weight: ");
                        weightInPounds = Console.ReadLine();
                    }
                    else
                    {
                        checkWeight  = true;
                        alreadyInput = true;
                    }
                }
            }
            Console.Write("  Please enter patient's height in inches: ");
            String heightInInches = Console.ReadLine();
            int    heightNum;
            bool   checkHeight = false;

            while (!checkHeight)
            {
                if (!int.TryParse(heightInInches, out heightNum))
                {
                    Console.WriteLine("  Error! Height must be a numeric value only.");
                    Console.Write("  Please enter patient's height: ");
                    heightInInches = Console.ReadLine();
                }
                else
                {
                    if (Convert.ToInt32(heightInInches) <= 0)
                    {
                        Console.WriteLine("  Error! Height must be a positive number only.");
                        Console.Write("  Please enter patient's height: ");
                        heightInInches = Console.ReadLine();
                    }
                    else
                    {
                        checkHeight  = true;
                        alreadyInput = true;
                    }
                }
            }
            Patient patient = new Patient(fName, lName, Convert.ToInt32(age), Convert.ToDouble(weightInPounds),
                                          Convert.ToDouble(heightInInches));

            return(patient);
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            TruongHeading.getHeading("Assignment 6");
            bool whileCheck = GetMaxQuestion();

            int  levelInput = 0;
            bool levelCheck = true;

            while (levelCheck && whileCheck == false)
            {
                Console.Write("  Please input the difficulty level (1 = easy, 2 = medium, 3 = hard): ");
                String input1 = Console.ReadLine();
                if (!int.TryParse(input1, out levelInput))
                {
                    Console.WriteLine(errorMessage("  Please input a numeric value only!\n"));
                }
                else if ((levelInput <= 0) || (levelInput > 3))
                {
                    Console.WriteLine(errorMessage("  Please enter a value between 1 and 3 only.\n"));
                }
                else
                {
                    levelCheck = false;
                }
            }

            int userResult = 0;
            MultiplicationGame multiplicationGame;
            int counter = 0;

            while (true)
            {
                counter++;
                multiplicationGame = new MultiplicationGame(levelInput);
                Console.Clear();
                TruongHeading.getHeading("Assignment 6");
                updateScore();
                Console.Write("\n  How much is {0} times {1}? ", multiplicationGame.randomNumber1, multiplicationGame.randomNumber2);
                String result = Console.ReadLine();

                if (!int.TryParse(result, out userResult))
                {
                    Console.WriteLine(errorMessage("  Error - please enter a numeric answer only!\n"));
                    Console.WriteLine("  Please press enter to continue");
                }
                else
                {
                    if (userResult != multiplicationGame.multiply())
                    {
                        Console.WriteLine("  Incorrect!\n  Press enter to continue");
                        incorrectNumAnswer++;
                        Console.ReadLine();
                    }
                    else
                    {
                        Console.WriteLine("  Correct!\n  Press enter to continue");
                        correctNumAnswer++;
                        Console.ReadLine();
                    }
                }

                if (counter == maxQuestion)
                {
                    Console.Clear();
                    TruongHeading.getHeading("Assignment 6");
                    printResult();
                    break;
                }
            }
            Console.ReadLine();
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            bool    alreadyInputInfo = false;
            int     height           = 0;
            double  weight           = 0;
            Boolean canExit          = false;

            //bool canExit = false;
            //while(canExit == false) {
            //   if(userInput == "3")  canExit = true;
            // }
            //while (true)
            while (!canExit)
            {
                Console.Clear();
                TruongHeading.getHeading("Assignment 5");
                // string errors = "";
                string menu = Menu();
                Console.WriteLine(menu);
                Console.Write("  Choice: ");
                string input = Console.ReadLine();
                int    inpValue;
                Console.Clear();
                //errors += "Error message";
                bool valid = Int32.TryParse(input, out inpValue);
                if (valid)
                {
                    // exit application
                    if (inpValue == 3)
                    {
                        Console.Clear();
                        TruongHeading.getHeading("Assignment 5");
                        Console.WriteLine("  You have exited the program!");
                        TruongHeading.getClosing();
                        System.Environment.Exit(1);
                    }

                    if (inpValue == 1)
                    {
                        Console.Clear();
                        Console.WriteLine("  What is your height in inches: ");
                        Console.SetCursorPosition(33, 0);
                        bool   validInput  = false;
                        String inputHeight = Console.ReadLine();
                        //height = Int32.Parse(inputHeight);
                        while (!validInput)
                        {
                            if (Int32.TryParse(inputHeight, out height))
                            {
                                if (height < 0)
                                {
                                    Console.Clear();
                                    TruongHeading.getHeading("Assignment 5");
                                    Console.WriteLine("  -------------------------------------");
                                    Console.WriteLine("  Error(s):\n    - Error, you must enter a number greater than zero for height!");
                                    Console.WriteLine("  -------------------------------------");
                                    Console.WriteLine("  Please input your height in inches:");
                                    String input3 = Console.ReadLine();
                                    height = Convert.ToInt32(input3);
                                }
                                else
                                {
                                    alreadyInputInfo = true;
                                    validInput       = true;
                                }
                            }
                            else
                            {
                                Console.Clear();
                                TruongHeading.getHeading("Assignment 5");
                                Console.WriteLine("  -------------------------------------");
                                Console.WriteLine("  Error(s):\n    - Error, enter a number only for height!");
                                Console.WriteLine("  -------------------------------------");
                                // DisplayMenu(err);   //""  //"Error: Enter a number"
                                Console.WriteLine("  Please input your height in inches:");
                                String input4 = Console.ReadLine();
                                bool   inWord = false;
                                while (!inWord)
                                {
                                    if (Int32.TryParse(input4, out height))
                                    {
                                        if (height < 0)
                                        {
                                            Console.Clear();
                                            TruongHeading.getHeading("Assignment 5");
                                            Console.WriteLine("  -------------------------------------");
                                            Console.WriteLine("  Error(s):\n    - Error, you must enter a number greater than zero for height!");
                                            Console.WriteLine("  -------------------------------------");
                                            Console.WriteLine("  Please input your height in inches:");
                                            String input3 = Console.ReadLine();
                                            height = Convert.ToInt32(input3);
                                        }
                                        else
                                        {
                                            alreadyInputInfo = true;
                                            inWord           = true;
                                        }
                                    }
                                    else
                                    {
                                        Console.Clear();
                                        TruongHeading.getHeading("Assignment 5");
                                        Console.WriteLine("  -------------------------------------");
                                        Console.WriteLine("  Error(s):\n    - Error, enter a number only for height!");
                                        Console.WriteLine("  -------------------------------------");
                                        Console.WriteLine("  Please input your height in inches:");
                                        input4 = Console.ReadLine();
                                        //break;
                                    }
                                }
                            }

                            Console.Clear();
                            Console.WriteLine("  What is your weight in pounds: ");
                            Console.SetCursorPosition(33, 0);
                            String inputWeight = Console.ReadLine();
                            //  weight = Convert.ToDouble(inputWeight);
                            if (Double.TryParse(inputWeight, out weight))
                            {
                                if (weight < 0)
                                {
                                    Console.Clear();
                                    TruongHeading.getHeading("Assignment 5");
                                    Console.WriteLine("  -------------------------------------");
                                    Console.WriteLine("  Error(s):\n    - Error, you must enter a number greater than zero for weight!");
                                    Console.WriteLine("  -------------------------------------");
                                    Console.WriteLine("  Please input your weight in pounds:");
                                    String input5 = Console.ReadLine();
                                }
                                else
                                {
                                    alreadyInputInfo = true;
                                    validInput       = true;
                                }
                            }
                            else
                            {
                                Console.Clear();
                                TruongHeading.getHeading("Assignment 5");
                                Console.WriteLine("  -------------------------------------");
                                Console.WriteLine("  Error(s):\n    - Error, enter a number only for weight!");
                                Console.WriteLine("  -------------------------------------");
                                Console.WriteLine("  Please input your weight in pounds:");
                                String input6  = Console.ReadLine();
                                bool   inWord1 = false;
                                while (!inWord1)
                                {
                                    if (Double.TryParse(input6, out weight))
                                    {
                                        if (height < 0)
                                        {
                                            Console.Clear();
                                            TruongHeading.getHeading("Assignment 5");
                                            Console.WriteLine("  -------------------------------------");
                                            Console.WriteLine("  Error(s):\n    - Error, you must enter a number greater than zero for height!");
                                            Console.WriteLine("  -------------------------------------");
                                            Console.WriteLine("  Please input your height in inches:");
                                            String input3 = Console.ReadLine();
                                            height = Convert.ToInt32(input3);
                                        }
                                        else
                                        {
                                            alreadyInputInfo = true;
                                            inWord1          = true;
                                        }
                                    }
                                    else
                                    {
                                        Console.Clear();
                                        TruongHeading.getHeading("Assignment 5");
                                        Console.WriteLine("  -------------------------------------");
                                        Console.WriteLine("  Error(s):\n    - Error, enter a number only for height!");
                                        Console.WriteLine("  -------------------------------------");
                                        Console.WriteLine("  Please input your height in inches:");
                                        input6 = Console.ReadLine();
                                    }
                                }
                            }
                        }
                    }
                    // option 2
                    if (inpValue == 2)
                    {
                        if (alreadyInputInfo == false)
                        {
                            Console.Clear();
                            TruongHeading.getHeading("Assignment 5");
                            Console.WriteLine("  Menu:");
                            Console.WriteLine("  ----------------------------------------");
                            Console.WriteLine("  Error(s):\n    - You must input user info (choice 1) before");
                            Console.WriteLine("      you can calculate BMI");
                            Console.WriteLine("  ----------------------------------------");
                            Console.WriteLine("  1). Input my information");
                            Console.WriteLine("  2). Display my BMI");
                            Console.WriteLine("  3). Exit\n");
                            Console.WriteLine("  Choice: ");
                            Console.SetCursorPosition(10, 16);
                            string input2    = Console.ReadLine();
                            bool   intInput2 = Int32.TryParse(input2, out inpValue);
                        }
                        else if (alreadyInputInfo == true)
                        {
                            Console.Clear();
                            TruongHeading.getHeading("Assignment 5");
                            Console.WriteLine("  BMI VALUES");
                            Console.WriteLine("  -------------------------------------------");
                            Console.WriteLine("  {0,-20}{1}", "Underweight:", "less than 18.5");
                            Console.WriteLine("  {0,-20}{1}", "Normal:", "between 18.5 and 24.9");
                            Console.WriteLine("  {0,-20}{1}", "Overweight", "between 25 and 29.9");
                            Console.WriteLine("  {0,-20}{1}", "Obese", "30 and greater");
                            Console.WriteLine("  -------------------------------------------");
                            Person person = new Person(height, weight);
                            Console.WriteLine(person.BMIName);
                            TruongHeading.getClosing();
                        }
                    }
                }//end valid
                else
                {
                    Console.Clear();
                    TruongHeading.getHeading("Assignment 5");
                    Console.WriteLine("  Menu:");
                    Console.WriteLine("  ----------------------------------------");
                    Console.WriteLine("  Error(s):\n");
                    Console.WriteLine("     - Input a number only (1-3)");
                    Console.WriteLine("  ----------------------------------------");
                    Console.WriteLine("  1). Input my information");
                    Console.WriteLine("  2). Display my BMI");
                    Console.WriteLine("  3). Exit\n");
                    Console.WriteLine("  Choice: ");
                    string input7    = Console.ReadLine();
                    bool   intInput7 = Int32.TryParse(input7, out inpValue);
                }
            } //end while
        }     //end main
        static void Main(string[] args)
        {
            Invoice[] myInvoice = new Invoice[8];
            Invoice   invoice1  = new Invoice(83, "Electric sander", 7, 57.98M);
            Invoice   invoice2  = new Invoice(24, "Power saw", 18, 99.99M);
            Invoice   invoice3  = new Invoice(7, "Sledge hammer", 11, 21.50M);
            Invoice   invoice4  = new Invoice(77, "Hammer", 76, 11.99M);
            Invoice   invoice5  = new Invoice(39, "Lawn mower", 3, 79.50M);
            Invoice   invoice6  = new Invoice(68, "Screwdriver", 106, 6.99M);
            Invoice   invoice7  = new Invoice(56, "Jig saw", 21, 11.00M);
            Invoice   invoice8  = new Invoice(3, "Wrench", 34, 7.50M);

            myInvoice[0] = invoice1;
            myInvoice[1] = invoice2;
            myInvoice[2] = invoice3;
            myInvoice[3] = invoice4;
            myInvoice[4] = invoice5;
            myInvoice[5] = invoice6;
            myInvoice[6] = invoice7;
            myInvoice[7] = invoice8;

            //sort the Invoice Objects by PartDescription
            var sortPartDescription = from item in myInvoice orderby item.PartDescription select item;

            TruongHeading.getHeading("Assignment 8");
            Console.WriteLine("  {0, -18}{1, -20}{2, -20}{3, -20}", "Part number", "Part description",
                              "Quantity", "Price");
            Console.WriteLine("  {0, -18}{1, -20}{2, -20}{3, -20}", "-----------", "----------------",
                              "----------", "------");

            //item is element we name it, item of the what? is the part we need to do. Then select the element item.

            foreach (Invoice invoiceItem in sortPartDescription) // sort it from the part holds sort.
            {
                Console.WriteLine("  {0, -18}{1, -20}{2, -20}${3, -20}", invoiceItem.PartNumber,
                                  invoiceItem.PartDescription, invoiceItem.Quantity, invoiceItem.Price);
            }

            //sort the Invoice objects by Price
            var sortPrice = from sortList in myInvoice orderby sortList.Price select sortList;

            Console.WriteLine("  -----------------------------------------------------------------------\n");
            Console.WriteLine("  {0, -18}{1, -20}{2, -20}{3, -20}", "Part number", "Part description",
                              "Quantity", "Price");
            Console.WriteLine("  {0, -18}{1, -20}{2, -20}{3, -20}", "-----------", "----------------",
                              "----------", "------");
            foreach (Invoice invoiceItem in sortPrice)
            {
                Console.WriteLine("  {0, -18}{1, -20}{2, -20}${3, -20}", invoiceItem.PartNumber,
                                  invoiceItem.PartDescription, invoiceItem.Quantity, invoiceItem.Price);
            }

            var sortBoth = from element in myInvoice
                           orderby element.Quantity
                           select new { element.PartDescription, element.Quantity };

            Console.WriteLine("  -------------------------------------------------------------------------\n");
            Console.WriteLine("  {0, -18}{1, -20}", "Part description", "Quantity");
            Console.WriteLine("  {0, -18}{1, -20}", "----------------", "--------");
            //var secondSort = from something in myInvoice orderby something.Quantity select sortBoth;
            foreach (var abc in sortBoth)
            {
                Console.WriteLine("  {0, -18}{1, -20}", abc.PartDescription, abc.Quantity);
            }
            //Select from each Invoice the PartDescription and the value of the
            //Invoice.(InvoicceTotal). Order resutls by Invoice value.

            var sortInvoiceValue = from sortInvoice in myInvoice
                                   let InvoiceTotal = sortInvoice.Quantity * sortInvoice.Price
                                                      orderby InvoiceTotal
                                                      select new { sortInvoice.PartDescription, InvoiceTotal };

            Console.WriteLine("  -----------------------------------------------\n");
            Console.WriteLine("  {0, -18}{1, -30}", "Part description", "Invoice Total");
            Console.WriteLine("  {0, -18}{1, -30}", "----------------", "-------------");

            foreach (var sortInv in sortInvoiceValue)
            {
                Console.WriteLine("  {0, -18} ${1, -20}", sortInv.PartDescription, sortInv.InvoiceTotal);
            }


            //Using results of the LinQ query in Part d, select  the InvoiceTotals in the range $200 to $500
            var sortNumber = from sortNumberRange in sortInvoiceValue
                             where sortNumberRange.InvoiceTotal >= 200 && sortNumberRange.InvoiceTotal <= 500
                             select sortNumberRange;

            Console.WriteLine("  -----------------------------------------------\n");
            Console.WriteLine("  {0, -18}{1, -30}", "Part description", "Invoice Total");
            Console.WriteLine("  {0, -18}{1, -30}", "----------------", "-------------");
            foreach (var resultSortInvoice in sortNumber)
            {
                Console.WriteLine("  {0, -18} ${1, -20}", resultSortInvoice.PartDescription,
                                  resultSortInvoice.InvoiceTotal);
            }
            TruongHeading.getClosing();
            Console.ReadLine();


            //var sortPart = blabla;
            //List<Inventory> = SortParts.ToList<Inventory>();
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            decimal balance        = 2000;
            decimal yearInterest   = 0.04M;
            decimal feeTransaction = 10.00M;

            TruongHeading.getHeading("Assignment 10");
            Account account = new Account(balance);

            Console.WriteLine("  The balance is {0}", balance);

            account.Credit(200);
            Console.WriteLine("  The balance credit $200 is {0}", account.bankBalance);

            try
            {
                account.Debit(300);
                Console.WriteLine("  The balance debit $300 is {0}", account.bankBalance);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            SavingsAccount savingAccount = new SavingsAccount(balance, yearInterest);

            Console.WriteLine("\n  The saving account: ");
            Console.WriteLine("  The new balance is {0} ", savingAccount.GetBalance());

            Console.WriteLine("  The interest amount is {0}", savingAccount.CalculateInterest());

            savingAccount.Credit(savingAccount.CalculateInterest());
            Console.WriteLine("  The new balance is {0} ", savingAccount.GetBalance());


            CheckingAccount checkingAccount = new CheckingAccount(balance, feeTransaction);

            Console.WriteLine("\n  The checking account: ");
            Console.WriteLine("  The checking balance account is {0}", checkingAccount.GetBalance());
            try
            {
                checkingAccount.Debit(500M);
                Console.WriteLine("  The checking balance account debit $500 is {0}", checkingAccount.Debit(500));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            try
            {
                checkingAccount.Debit(2500M);
                Console.WriteLine("  The checking balance debit $2500 is {0}", checkingAccount.Debit(2500));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            TruongHeading.getClosing();
            Console.ReadLine();
        }