Write a static method called dollarToPeso that takes a dollar amount as parameter and returns its equivalent in pesos. Assume that the conversion rate is 1 dollar = 48.45 pesos. Use this method in the program.
Sample output:
Enter dollar amount: 50
$ 50 = P 2,422.5
import java.util.Scanner;
public class Main {
public static void dollarToPeso(Scanner in){
System.out.print("Enter dollar amount: ");
double dol = in.nextDouble();
System.out.println("$ " + dol + " = " + "P " + (dol*48.45));
}
public static void main(String[] args){
Scanner in = new Scanner(System.in);
Main.dollarToPeso(in);
}
}
Comments
Leave a comment