+ 1
Can someone please help me with this code for the code coach Argentina?
It always outputs Pesos. This is my code: public class Program { public static void main(String[] args) { double Pesos=1; double Dollars=0.02; double p=(Dollars*0.02); double d=(Pesos/0.02); if(p<d) { System.out.println("Pesos"); }if (p>d) { System.out.println("Dollars"); } } }
4 Answers
+ 2
Thank you Rostislsv!
+ 1
Btw I also tried using an else statement. Idk if I used it correctly though.
+ 1
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int pesos = input.nextInt();
int dolars = input.nextInt();
if(pesos/80<dolars){
System.out.println("Pesos");
}else{
System.out.println("Dollars");
}
}
}
+ 1
dont convert both values either convert dollar to pesos and compare it to pesos or convert pesos to dollar and compare it to dollar
eg:
public class Program
{
public static void main(String[] args) {
double Pesos=1;
double Dollars=0.02;
double p=(Dollars*0.02);
if(p<Dollars) { System.out.println("Pesos");
}if (p>Dollars) { System.out.println("Dollars");
}
}
}