C# Problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

C# Problem

You are in a hat store in Argentina! The prices are listed in US Dollars and Argentinian Pesos. You have both, but you want to make sure you pay the lower price! Do you pay in Dollars or Pesos? The exchange rate is 2 cents for every Peso. Task Create a program that takes two prices and tells you which one is lower after conversion. Input Format Two integer values, the first one is the price in Pesos and the second one is the price in Dollars. Output Format A string that says which currency you should make the purchase in ('Dollars' or 'Pesos'). Sample Input 4000 100 Sample Output Pesos using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int pesos = Convert.ToInt32(Console.ReadLine()); int dollars = Convert.ToInt32(Console.ReadLine()); int cents=dollars*100; int pesoseddol=cents/2; if(pesoseddol>pesos) { Console.WriteLine("Pesos"); } else { Console.WriteLine("Dollars"); }; } } } I’m new to C# and I have a problem. Can you say what I did wrong? All the cases are working except the last one.

2nd Mar 2021, 10:21 AM
Ani Arzumanyan
4 Answers
+ 7
It says 1 pesos = 0.02 dollars and you get dollar and pesos in input so you can convert the dollars to pesos and check which is greater double pesosConvert = pesos * 0.02; if(pesosConvert > dollars)
2nd Mar 2021, 10:27 AM
Sharique Khan
Sharique Khan - avatar
+ 4
Your Welcome 😊glad to hear you issue was resolved. Ani Arzumanyan
2nd Mar 2021, 10:32 AM
Sharique Khan
Sharique Khan - avatar
+ 2
Thank you so much Sharique Khan . I just converted the int into double and it worked.
2nd Mar 2021, 10:31 AM
Ani Arzumanyan
+ 1
And 'Console.Readline();'
17th Jul 2021, 8:01 AM
Tolga Gacar
Tolga Gacar - avatar