第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

具有三個(gè)公共屬性的加法 3 個(gè)私有雙數(shù)據(jù)成員的計(jì)算器

具有三個(gè)公共屬性的加法 3 個(gè)私有雙數(shù)據(jù)成員的計(jì)算器

C#
縹緲止盈 2022-01-09 16:44:23
計(jì)算器版本 1創(chuàng)建一個(gè)控制臺(tái)項(xiàng)目。將“Program.cs”重命名為“CalculatorRun.cs”添加類“Calculator.cs” - 具有三個(gè)公共屬性的 3 個(gè)私有雙數(shù)據(jù)成員 - firstOperand、FirstOperand;- 第二操作數(shù),第二操作數(shù);- 結(jié)果,結(jié)果;1 公共方法 Addition()在這個(gè)方法中做加法,Result = FirstOperand + SecondOperand;在“CalculatorRun.cs”中,讓用戶輸入 firstOperand 和 secondOperand 的值,顯示添加結(jié)果。我已經(jīng)為此工作了幾個(gè)小時(shí),但仍然沒有任何意義。我的代碼沒用。有人有意見嗎?這就是我所擁有的:namespace CalculatorRun{    class Calculator    {        static void Main(string[] args)        {            decimal FirstOperand, SecondOperand, Result, result;            Console.Write("Addition Calculation");            Console.Write("      \n\n");            Console.Write("   Enter first operand:       ");            FirstOperand = Convert.ToDecimal(Console.ReadLine());            Console.Write("   Enter second operand:      ");            SecondOperand = Convert.ToDecimal(Console.ReadLine());            Console.Write("-------------------------\n\n");            Result = FirstOperand + SecondOperand;            result = Convert.ToDecimal(Result);            Console.WriteLine("Addition Result: {0}", string.Format("{0}", result));            Console.WriteLine("Press any key to continue.....");            Console.ReadLine();        }    }}但它需要更像這樣(當(dāng)然使用頂部的說明)。但是當(dāng)我嘗試過它時(shí),我無法讓它工作。:使用系統(tǒng);namespace Calculator{    class Program    {        public static void Main(string[] args)        {        }//<-----------        public int number01;        public int number02;        public int Number03        {            get            {                return number02 / number01;            }        }//<----------    }}
查看完整描述

1 回答

?
哆啦的時(shí)光機(jī)

TA貢獻(xiàn)1779條經(jīng)驗(yàn) 獲得超6個(gè)贊

這將為您完成。評(píng)論中的解釋:


using System;


namespace ConsoleApplication1 {

    class Program {


        static void Main( string[] args ) {

            Calculator calculator = new Calculator();


            Console.Write( "   Enter first operand:       " );


            calculator.FirstOperand = Convert.ToDouble( Console.ReadLine() ); //get the first


            Console.Write( "   Enter first operand:       " );


            calculator.SecondOperand = Convert.ToDouble( Console.ReadLine() ); //get the second


            calculator.Addition(); //Do addition


            Console.WriteLine( "Addition Result: {0}", calculator.Result ); //show result


            Console.WriteLine( "Press any key to continue....." );

            Console.ReadLine();

        }


    }


    class Calculator {

        private double firstOperand, secondOperand, result; //double data members


        //3 public properties

        public double FirstOperand {

            get { return firstOperand; }

            set { firstOperand = value; }

        }


        public double SecondOperand {

            get { return secondOperand; }

            set { secondOperand = value; }

        }


        public double Result {

            get { return result; }

            set { result = value; }

        }


        //1 public method Addition()

        public double Addition() {

            return result = firstOperand + secondOperand;

        }


    }


}


查看完整回答
反對(duì) 回復(fù) 2022-01-09
  • 1 回答
  • 0 關(guān)注
  • 164 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)