練習 - 完成將字串插補套用至表單字母的挑戰

已完成

對於銷售與行銷公司最新的投資產品,您會將數千封個人化信件傳送給公司現有的客戶。 您的作業是撰寫 C# 程式代碼,以合併客戶的個人化資訊。 這封信包含其現有投資組合等資訊,並比較其目前的回報與預計的回報,如果他們要使用新產品進行投資。

作者已決定下列範例行銷訊息。 以下是所需的輸出(使用虛構的客戶帳戶數據)。

Dear Ms. Barros,
As a customer of our Magic Yield offering we are excited to tell you about a new financial product that would dramatically increase your return.

Currently, you own 2,975,000.00 shares at a return of 12.75%.

Our new product, Glorious Future offers a return of 13.13%.  Given your current volume, your potential profit would be ¤63,000,000.00.

Here's a quick comparison:

Magic Yield         12.75%   $55,000,000.00      
Glorious Future     13.13%   $63,000,000.00  

使用您新找到的字串格式知識來建置應用程式,以在先前的範例輸出中合併和格式化適當的內容。 請特別注意空格符,並確定您使用 C# 正確地表示此確切格式。

  1. 選取並刪除 Visual Studio Code 編輯器中的所有程式代碼行。

  2. 在 Visual Studio Code 中,新增下列程式碼以取得挑戰的資料:

    string customerName = "Ms. Barros";
    
    string currentProduct = "Magic Yield";
    int currentShares = 2975000;
    decimal currentReturn = 0.1275m;
    decimal currentProfit = 55000000.0m;
    
    string newProduct = "Glorious Future";
    decimal newReturn = 0.13125m;
    decimal newProfit = 63000000.0m;
    
    // Your logic here
    
    Console.WriteLine("Here's a quick comparison:\n");
    
    string comparisonMessage = "";
    
    // Your logic here
    
    Console.WriteLine(comparisonMessage);
    
  3. 使用 Visual Studio Code 編輯器,在使用指定的變數和程式代碼時產生訊息。

    您不一定刪除任何現有的程式代碼,但批註除外。

  4. 請確定您的程式代碼會輸出下列訊息:

    Dear Ms. Barros,
    As a customer of our Magic Yield offering we are excited to tell you about a new financial product that would dramatically increase your return.
    
    Currently, you own 2,975,000.00 shares at a return of 12.75%.
    
    Our new product, Glorious Future offers a return of 13.13%.  Given your current volume, your potential profit would be $63,000,000.00.
    
    Here's a quick comparison:
    
    Magic Yield         12.75%   $55,000,000.00      
    Glorious Future     13.13%   $63,000,000.00  
    

祝你好運!

無論您是停滯不前,需要查看解決方案,還是您順利完成,請繼續檢視此挑戰的解決方案。