Write a program that repeatedly asks the user to enter two money amounts expressed in pounds. The program should then add the two amounts and display the answer in pounds. The program should then convert the amount in Rupees. (Set conversion rate: 1£=120.33 rupees). Display the answer in Naira. Use a do-while loop that asks the user whether the program should be terminated.
public const double RUPEES_CONVERSATION_RATE = 120.33;
public const double NAIRA_CONVERSATION_RATE = 5.44;
public static void Main()
{
var askUser = true;
do
{
Console.WriteLine("Please enter 2 money amount");
var firstMoneyAmount = double.Parse(Console.ReadLine());
var secondMoneyAmount = double.Parse(Console.ReadLine());
var sum = firstMoneyAmount + secondMoneyAmount;
var sumInRupies = ConvertToRupies(sum);
var sumInNaira = ConvertRupiesToNaira(sumInRupies);
Console.WriteLine("Sum in Naira = " + sumInNaira);
askUser = bool.Parse(Console.ReadLine());
}
while (askUser == true);
}
private static double ConvertToRupies(double moneyAmount) {
return moneyAmount * RUPEES_CONVERSATION_RATE;
}
private static double ConvertRupiesToNaira(double moneyAmount) {
return moneyAmount * NAIRA_CONVERSATION_RATE;
}
Comments
Leave a comment