Extra Credit didn't matching for the Exercise - Update your calculated values

Chirag Sitapara 0 Reputation points
2024-02-29T00:46:11.1+00:00

Hi This is Chirag Sitapara, I'm going through > Exercise - Update your calculated values module. found that the output of the program file isn't matching as listed in the doc. I have attached both mine and the MS screenshot please update the doc. if required. thanks MS: https://learn.microsoft.com/en-us/training/modules/challenge-project-arrays-iteration-selection/4-exercise-update-calculations User's image

Mine: User's image

Developer technologies | C#
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-02-29T03:19:33.5266667+00:00

    Hi @Chirag Sitapara , Welcome to Microsoft Q&A,

    You can check out the tutorial "During calculations, you need to use (decimal) casts in equations to preserve the decimal part." A common method is to use the Math.Round () function. This function rounds a Decimal type variable to a specified number of decimal places. For example, use Math.Round (d, 2) to preserve a Decimal type variable d to two decimal places.

    You can also use Decimal.Round().

    double originalValue = 3.14159;
    decimal roundedValue = (decimal)originalValue; // Forced type conversion
    roundedValue = Decimal.Round(roundedValue, 1); // Set the precision to 1 decimal place
    Console.WriteLine(roundedValue);
    

    Best Regards,

    Jiale


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.