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 #2
0
    public static void Main(string[] args)
    {
        TruongHeading.getHeading("Assignment 4");
        Sales application = new Sales();

        application.CalculateSales();
        TruongHeading.getClosing();
        Console.Read();
    } // end Main
Beispiel #3
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();
        }
Beispiel #5
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 #7
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();
        }