0

About the Argentina coach code

What will happen if the price in pesos is equal to the price in dollars , i almost solved solved the problem still have one case which is not verified and it s hidden .

2nd Feb 2021, 8:22 AM
Nassera
Nassera - avatar
7 Antworten
+ 4
TheGirlHasNoName oh! Even I had this problem. They have not mentioned, but the input can be a float too. So change type of all the variables to `float` and instead of int input, take float input.
2nd Feb 2021, 9:09 AM
XXX
XXX - avatar
+ 4
My solution works and it only outputs "Pesos" when price in pesos is *smaller than* that in dollars. So even if the prices are equal, it outputs "Dollars".
2nd Feb 2021, 8:42 AM
XXX
XXX - avatar
+ 2
a=int(input()) d=int(input()) if (a*2)/100 <d: print('Pesos') else: print('Dollars')
2nd Feb 2021, 5:44 PM
Dipayan Dasgupta
Dipayan Dasgupta - avatar
+ 1
Thanks , the problem wasn't in my code but they did not mention the variables can be float , now it works and i dod solve it using java
2nd Feb 2021, 5:48 PM
Nassera
Nassera - avatar
0
Okay let me try if it doesn't work ill post my solution and thanks XXX
2nd Feb 2021, 8:46 AM
Nassera
Nassera - avatar
0
import java.util.Scanner ; public class Program { public static void main(String[] args) { Scanner input=new Scanner (System .in); int costPesos=input.nextInt(); int costDollar=input.nextInt(); int pesostocents=2*costPesos; int dollartocents=100*costDollar; if(pesostocents<dollartocents){ System .out.println("Pesos"); }else{ System .out.println ("Dollars"); } } }
2nd Feb 2021, 8:48 AM
Nassera
Nassera - avatar
0
Thanks XXX it works yes the problem is fixed once i switched the type to float
2nd Feb 2021, 9:25 AM
Nassera
Nassera - avatar