Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using static System.Net.Mime.MediaTypeNames;
- namespace _3.RoundingNumbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Read an array of real numbers (space separated), round them in "away from 0" style and print the output
- string input = Console.ReadLine();
- string[] userInputStringArray = input.Split();
- double[] userInputDoubleArray = new double[userInputStringArray.Length];
- for (int i = 0; i < userInputStringArray.Length; i++)
- {
- userInputDoubleArray[i] = double.Parse(userInputStringArray[i]);
- }
- for (int i = 0; i < userInputDoubleArray.Length; i++)
- {
- Console.WriteLine($"{Convert.ToDecimal(userInputDoubleArray[i])} => {Math.Round(Convert.ToDecimal(userInputDoubleArray[i]), MidpointRounding.AwayFromZero)}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment