Write a statement that prints the value of price in the form “X dollars and Y cents” on a line by itself.
So, if the value of price was 2345, your code would print “23 dollars and 45 cents”.
If the value was 501 it would print “5 dollars and 1 cents”. If the value was 99 your code would print “0 dollars and 99 cents”.
Source Code:
1 2 3 4 5 6 7 8 9 10 11 12 | static void Main(string[] args) { Console.Write("Please input your coins : "); int coins = int.Parse(Console.ReadLine()); int dollar,cent; dollar = coins / 100; cent = coins % 100; Console.WriteLine("{0} dollar and {1} coins", dollar, cent); Console.ReadLine(); } |
Output: