演習 - フォーム文字に文字列補間を適用する課題を完了する

完了

販売およびマーケティング会社の最新の投資製品については、会社の既存のクライアントに何千ものパーソナライズされた手紙を送信します。 あなたの仕事は、顧客に関するパーソナライズされた情報をマージする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  
    

がんばってください。

行き詰まって解答を見る必要がある場合でも、無事完了した場合でも、この課題の解答を引き続きご覧ください。