Untitled

mail@pastecode.io avatar
unknown
java
3 years ago
732 B
2
Indexable
Never
import java.util.Scanner;

public class Currency {
 	/***
 	 * 	
 	 * @param value of money in lbp
 	 * @param rate of conversion
 	 */
	public void toEuro(double value, double rate) {
		if (value > 0) {
			value = value * rate;
			System.out.println("You have entered a number equal to: " + value);
		} else {
			System.out.println("Error, You have entered a negative number");
		}
	}

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		double number = 0.00;
		double rate = 0.00059;
		Currency lbp = new Currency();

		System.out.print("Enter a positive number in LBP: ");
		String str = input.nextLine();
		number = Double.parseDouble(str);

		lbp.toEuro(number, rate);

		input.close();
	}

}