Write a program to convert currencies between British currency of pounds and pence, in which 1 pound contains 100 pence.
Write a statement that prints the value of price in the form “X pounds and Y pence” on a line by itself.
So, if the value of price was 2345, your code would print “23 pounds and 45 pence”.
If the value was 501 it would print “5 pounds and 1 pence ”.
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 pence : "); int coins = int.Parse(Console.ReadLine()); int pound, pence; pound = coins / 100; pence = coins % 100; Console.WriteLine("{0} pounds and {1} pence", pound, pence); Console.ReadLine(); } |
Output: