Answer to Question #287152 in C# for Kayla

Question #287152

Create a program that will allow the user to input a 3 digit number and program will then break the number into 3 separate values and display the difference from the first number from 9, the second number from 12 and the third number from 15.

1
Expert's answer
2022-01-13T03:56:52-0500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Please, input a 3 digit number");
            string num = Console.ReadLine();
            int firstNum = Convert.ToInt32(num[0].ToString());
            int secondNum = Convert.ToInt32(num[1].ToString());
            int thirdNum = Convert.ToInt32(num[2].ToString());

            Console.WriteLine($"9 - {firstNum} = {9 - firstNum}");
            Console.WriteLine($"12 - {secondNum} = {12 - secondNum}");
            Console.WriteLine($"15 - {thirdNum} = {15 - thirdNum}");

            Console.ReadKey();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS