コード例 #1
0
        static void Main(string[] args)
        {
            DivSales [] myDivisions = new DivSales[6];
            for (int i = 0; i < 6; i++)
            {
                myDivisions[i] = new DivSales();
            }
            Console.WriteLine("Please enter the quarterly sales for the first division.\nEnter them one at a time. I.E. amount then enter key.");
            myDivisions[0].setQuarterlySales(0, double.Parse(Console.ReadLine()));
            myDivisions[0].setQuarterlySales(1, double.Parse(Console.ReadLine()));
            myDivisions[0].setQuarterlySales(2, double.Parse(Console.ReadLine()));
            myDivisions[0].setQuarterlySales(3, double.Parse(Console.ReadLine()));
            Console.WriteLine("Please enter the quarterly sales for the second division.\nEnter them one at a time. I.E. amount then enter key.");
            myDivisions[1].setQuarterlySales(0, double.Parse(Console.ReadLine()));
            myDivisions[1].setQuarterlySales(1, double.Parse(Console.ReadLine()));
            myDivisions[1].setQuarterlySales(2, double.Parse(Console.ReadLine()));
            myDivisions[1].setQuarterlySales(3, double.Parse(Console.ReadLine()));
            Console.WriteLine("Please enter the quarterly sales for the third division.\nEnter them one at a time. I.E. amount then enter key.");
            myDivisions[2].setQuarterlySales(0, double.Parse(Console.ReadLine()));
            myDivisions[2].setQuarterlySales(1, double.Parse(Console.ReadLine()));
            myDivisions[2].setQuarterlySales(2, double.Parse(Console.ReadLine()));
            myDivisions[2].setQuarterlySales(3, double.Parse(Console.ReadLine()));
            Console.WriteLine("Please enter the quarterly sales for the fourth division.\nEnter them one at a time. I.E. amount then enter key.");
            myDivisions[3].setQuarterlySales(0, double.Parse(Console.ReadLine()));
            myDivisions[3].setQuarterlySales(1, double.Parse(Console.ReadLine()));
            myDivisions[3].setQuarterlySales(2, double.Parse(Console.ReadLine()));
            myDivisions[3].setQuarterlySales(3, double.Parse(Console.ReadLine()));
            Console.WriteLine("Please enter the quarterly sales for the fifth division.\nEnter them one at a time. I.E. amount then enter key.");
            myDivisions[4].setQuarterlySales(0, double.Parse(Console.ReadLine()));
            myDivisions[4].setQuarterlySales(1, double.Parse(Console.ReadLine()));
            myDivisions[4].setQuarterlySales(2, double.Parse(Console.ReadLine()));
            myDivisions[4].setQuarterlySales(3, double.Parse(Console.ReadLine()));
            Console.WriteLine("Please enter the quarterly sales for the sixth division.\nEnter them one at a time. I.E. amount then enter key.");
            myDivisions[5].setQuarterlySales(0, double.Parse(Console.ReadLine()));
            myDivisions[5].setQuarterlySales(1, double.Parse(Console.ReadLine()));
            myDivisions[5].setQuarterlySales(2, double.Parse(Console.ReadLine()));
            myDivisions[5].setQuarterlySales(3, double.Parse(Console.ReadLine()));

            for (int i = 0; i < 6; i++)
            {
                myDivisions[i].addToCorporateSales();
            }
            Console.WriteLine("Corporate Sales Output:");
            for (int i = 0; i < 6; i++)
            {
                Console.WriteLine("Division " + (i + 1) + ":");
                for (int j = 0; j < 4; j++)
                {
                    Console.WriteLine("Quarter " + (j + 1) + ": " + myDivisions[i].getQuarterSales(j));
                }
            }
            Console.WriteLine("Total Corporate Sales: " + DivSales.getTotalCorporateSales() + ".");
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: martialbob/CorporateSales
        static void Main(string[] args)
        {
            DivSales [] myDivisions = new DivSales[6];
            for (int i = 0; i < 6; i++)
                myDivisions[i] = new DivSales();
            Console.WriteLine("Please enter the quarterly sales for the first division.\nEnter them one at a time. I.E. amount then enter key.");
            myDivisions[0].setQuarterlySales(0, double.Parse(Console.ReadLine()));
            myDivisions[0].setQuarterlySales(1, double.Parse(Console.ReadLine()));
            myDivisions[0].setQuarterlySales(2, double.Parse(Console.ReadLine()));
            myDivisions[0].setQuarterlySales(3, double.Parse(Console.ReadLine()));
            Console.WriteLine("Please enter the quarterly sales for the second division.\nEnter them one at a time. I.E. amount then enter key.");
            myDivisions[1].setQuarterlySales(0, double.Parse(Console.ReadLine()));
            myDivisions[1].setQuarterlySales(1, double.Parse(Console.ReadLine()));
            myDivisions[1].setQuarterlySales(2, double.Parse(Console.ReadLine()));
            myDivisions[1].setQuarterlySales(3, double.Parse(Console.ReadLine()));
            Console.WriteLine("Please enter the quarterly sales for the third division.\nEnter them one at a time. I.E. amount then enter key.");
            myDivisions[2].setQuarterlySales(0, double.Parse(Console.ReadLine()));
            myDivisions[2].setQuarterlySales(1, double.Parse(Console.ReadLine()));
            myDivisions[2].setQuarterlySales(2, double.Parse(Console.ReadLine()));
            myDivisions[2].setQuarterlySales(3, double.Parse(Console.ReadLine()));
            Console.WriteLine("Please enter the quarterly sales for the fourth division.\nEnter them one at a time. I.E. amount then enter key.");
            myDivisions[3].setQuarterlySales(0, double.Parse(Console.ReadLine()));
            myDivisions[3].setQuarterlySales(1, double.Parse(Console.ReadLine()));
            myDivisions[3].setQuarterlySales(2, double.Parse(Console.ReadLine()));
            myDivisions[3].setQuarterlySales(3, double.Parse(Console.ReadLine()));
            Console.WriteLine("Please enter the quarterly sales for the fifth division.\nEnter them one at a time. I.E. amount then enter key.");
            myDivisions[4].setQuarterlySales(0, double.Parse(Console.ReadLine()));
            myDivisions[4].setQuarterlySales(1, double.Parse(Console.ReadLine()));
            myDivisions[4].setQuarterlySales(2, double.Parse(Console.ReadLine()));
            myDivisions[4].setQuarterlySales(3, double.Parse(Console.ReadLine()));
            Console.WriteLine("Please enter the quarterly sales for the sixth division.\nEnter them one at a time. I.E. amount then enter key.");
            myDivisions[5].setQuarterlySales(0, double.Parse(Console.ReadLine()));
            myDivisions[5].setQuarterlySales(1, double.Parse(Console.ReadLine()));
            myDivisions[5].setQuarterlySales(2, double.Parse(Console.ReadLine()));
            myDivisions[5].setQuarterlySales(3, double.Parse(Console.ReadLine()));

            for (int i = 0; i < 6; i++)
            {
                myDivisions[i].addToCorporateSales();
            }
            Console.WriteLine("Corporate Sales Output:");
            for (int i = 0; i < 6; i++)
            {
                Console.WriteLine("Division " + (i + 1) + ":");
                for (int j = 0; j < 4; j++)
                {
                    Console.WriteLine("Quarter " + (j+1) + ": " + myDivisions[i].getQuarterSales(j));
                }
            }
            Console.WriteLine("Total Corporate Sales: " + DivSales.getTotalCorporateSales() + ".");
        }