currencyConverter.
java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Question1;
/**
*
* @author Nasuha
*/
public class CurrencyConverter {
private String fromCurrency;
private String toCurrency;
private double conversionValue;
private double convertedValue;
public CurrencyConverter(String fromCurrency, String toCurrency, int conversionValue) {
[Link] = fromCurrency;
[Link] = toCurrency;
[Link] = conversionValue;
}
public double convertValue(double convertedValue) {
return convertedValue;
}
public double setConvertedValue(double convertedValue) {
[Link] = convertedValue;
return convertedValue;
}
public double currencyConvert(double newConvertValue) {
int choose, choose2;
double x, y, z;
double conversionAmount;
double rm = 4.73950;
double euro = 0.210993;
double rupiah = 3509.79;
return newConvertValue;
}
public void displayInfo() {
[Link]("RM Value : ");
[Link]("Euro Value : ");
[Link]("Indonesian Rupiah Value : ");
}
}
[Link]
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Question1;
import [Link];
/**
*
* @author Nasuha
*/
public class TestCurrencyConverter {
public static void main(String arg[]) {
Scanner scan = new Scanner([Link]);
[Link]("CURRENCY CONVERTER");
[Link]("----------------------------------------");
[Link]("Choose currency to be converted");
[Link]("FROM [1:Ringgit Malaysia 2:Euro 3:Indonesian Rupiah] : ");
int choice = [Link]();
String inType = null;
switch (choice) {
case 1:
inType = "RM";
break;
case 2:
inType = "Euro";
break;
case 3:
inType = "Rupiah";
default:
[Link]("Choose again");
}
[Link]("TO [1:Ringgit Malaysia 2:Euro 3:Indonesian Rupiah] : ");
int choice2 = [Link]();
String inType1 = null;
switch (choice2) {
case 1:
inType1 = "RM";
break;
case 2:
inType1 = "Euro";
break;
case 3:
inType1 = "Rupiah";
default:
[Link]("Choose again");
}
[Link]("Enter the conversion amount : ");
double conversionValue = [Link]();
if (choice == 1 && choice2 == 1) {
[Link]("----------------------------------------");
[Link]("SAME CURRENCY!");
}
if (choice == 1 && choice2 == 2) {
double euro = 0.210993;
double rate = conversionValue * euro;
[Link]("----------------------------------------");
[Link]("Currency converted : %.4f ", rate);
}
if (choice == 1 && choice2 == 3) {
double rupiah = 3509.79;
double rate = conversionValue * rupiah;
[Link]("----------------------------------------");
[Link]("Currency converted : %.4f ", rate);
}
if (choice == 2 && choice2 == 1) {
double rm = 4.73950;
double rate = conversionValue * rm;
[Link]("----------------------------------------");
[Link]("Currency converted : %.4f ", rate);
}
if (choice == 2 && choice2 == 2) {
[Link]("----------------------------------------");
[Link]("SAME CURRENCY!");
}
if (choice == 2 && choice2 == 3) {
double rupiah = 3509.79;
double rate = conversionValue * rupiah;
[Link]("----------------------------------------");
[Link]("Currency converted : %.4f ", rate);
}
if (choice == 3 && choice2 == 1) {
double rm = 4.73950;
double rate = conversionValue * rm;
[Link]("----------------------------------------");
[Link]("Currency converted : %.4f ", rate);
}
if (choice == 3 && choice2 == 2) {
double euro = 0.210993;
double rate = conversionValue * euro;
[Link]("----------------------------------------");
[Link]("Currency converted : %.4f ", rate);
}
if (choice == 3 && choice2 == 3) {
[Link]("----------------------------------------");
[Link]("SAME CURRENCY");
}
}
}
Output