練習 - 完成將字串內插補點套用至表單字母的挑戰
對於銷售和市場行銷公司的最新投資產品,您將會傳送數千封個人化信函給公司的現有客戶。 您的工作是撰寫 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# 正確地表示這種確切格式。
選取並刪除 Visual Studio Code 編輯器中的所有程式碼行。
在 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);
使用 Visual Studio Code 編輯器在使用指定的變數和程式碼時產生訊息。
您不能刪除註解以外的任何現有程式碼。
請確定您的程式碼會輸出下列訊息:
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
祝您好運!
無論是遇到困難需要查看解決方案,還是已成功完成,都請繼續檢視此挑戰的解決方案。