Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
6 changes: 5 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<version>1.0-SNAPSHOT</version>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
</project>
Binary file added src/.DS_Store
Binary file not shown.
Binary file added src/main/.DS_Store
Binary file not shown.
Empty file removed src/main/java/DELETEME
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.zipcodewilmington.wutangfinancial.carolynnvansant;

public class CurrencyExchange {
//exchange rate table is computed in dollar to __

private Double money;

public static final Double US_DOLLAR = 1.00;
public static final Double EURO = 0.94;
public static final Double BRITISH_POUND = 0.82;
public static final Double INDIAN_RUPEE = 68.32;
public static final Double AUSTRALIAN_DOLLAR = 1.35;
public static final Double CANADIAN_DOLLAR = 1.32;
public static final Double SINGAPORE_DOLLAR = 1.43;
public static final Double SWISS_FRANK = 1.01;
public static final Double MALAYSIAN_RINGGIT = 4.47;
public static final Double JAPANESE_YEN = 115.84;
public static final Double CHINESE_YUAN_RENMINBI = 6.92;

public CurrencyExchange(){
this.money = money;
}


public static Double currencyRateConversion(Double firstRate, Double secondRate, Double money) {
Double conversion = (1 / firstRate)*secondRate;
Double currencyLast = Math.round(money * conversion * 100d)/100d;
return currencyLast;
}



}

153 changes: 153 additions & 0 deletions src/test/java/CurrencyExchangeTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@

import com.zipcodewilmington.wutangfinancial.carolynnvansant.CurrencyExchange;
import org.junit.Test;
import org.junit.Assert;

import static com.zipcodewilmington.wutangfinancial.carolynnvansant.CurrencyExchange.currencyRateConversion;


public class CurrencyExchangeTest {

@Test
public void testCurrencyRateConversion() {
//Given:
//public Double currencyRateConversion(Double firstRate, Double secondRate, Double money)
Double firstRate = CurrencyExchange.US_DOLLAR;
Double secondRate = CurrencyExchange.EURO;
Double money = (double)100000;
Double expectedAmount = (double)94000;

Double actualAmount = currencyRateConversion(firstRate, secondRate, money);

Assert.assertEquals(expectedAmount,actualAmount);
}



@Test
public void testCurrencyRateConversion2() {
//Given:
//public Double currencyRateConversion(Double firstRate, Double secondRate, Double money)
Double firstRate = CurrencyExchange.EURO;
Double secondRate = CurrencyExchange.US_DOLLAR;
Double money = (double)94000;
Double expectedAmount = (double)100000;

Double actualAmount = currencyRateConversion(firstRate, secondRate, money);

Assert.assertEquals(expectedAmount,actualAmount);
}

@Test
public void testCurrencyRateConversion3() {
//Given:
//public Double currencyRateConversion(Double firstRate, Double secondRate, Double money)
Double firstRate = CurrencyExchange.EURO;
Double secondRate = CurrencyExchange.BRITISH_POUND;
Double money = (double)100000;
Double expectedAmount = (double)87234.04;

Double actualAmount = currencyRateConversion(firstRate, secondRate, money);

Assert.assertEquals(expectedAmount,actualAmount);
}

@Test
public void testCurrencyRateConversion4() {
//Given:
//public Double currencyRateConversion(Double firstRate, Double secondRate, Double money)
Double firstRate = CurrencyExchange.BRITISH_POUND;
Double secondRate = CurrencyExchange.INDIAN_RUPEE;
Double money = (double)87234.04;
Double expectedAmount = (double)7268084.89;

Double actualAmount = currencyRateConversion(firstRate, secondRate, money);

Assert.assertEquals(expectedAmount,actualAmount);
}

@Test
public void testCurrencyRateConversion5() {
//Given:
//public Double currencyRateConversion(Double firstRate, Double secondRate, Double money)
Double firstRate = CurrencyExchange.INDIAN_RUPEE;
Double secondRate = CurrencyExchange.CANADIAN_DOLLAR;
Double money = (double)7268084.89;
Double expectedAmount = (double)140425.53;

Double actualAmount = currencyRateConversion(firstRate, secondRate, money);

Assert.assertEquals(expectedAmount,actualAmount);
}

@Test
public void testCurrencyRateConversion6() {
//Given:
//public Double currencyRateConversion(Double firstRate, Double secondRate, Double money)
Double firstRate = CurrencyExchange.CANADIAN_DOLLAR;
Double secondRate = CurrencyExchange.SINGAPORE_DOLLAR;
Double money = (double)140425.53;
Double expectedAmount = (double)152127.66;

Double actualAmount = currencyRateConversion(firstRate, secondRate, money);

Assert.assertEquals(expectedAmount,actualAmount);
}

@Test
public void testCurrencyRateConversion7() {
//Given:
//public Double currencyRateConversion(Double firstRate, Double secondRate, Double money)
Double firstRate = CurrencyExchange.SINGAPORE_DOLLAR;
Double secondRate = CurrencyExchange.SWISS_FRANK;
Double money = (double)152127.66;
Double expectedAmount = (double)107446.81;

Double actualAmount = currencyRateConversion(firstRate, secondRate, money);

Assert.assertEquals(expectedAmount,actualAmount);
}

@Test
public void testCurrencyRateConversion8() {
//Given:
//public Double currencyRateConversion(Double firstRate, Double secondRate, Double money)
Double firstRate = CurrencyExchange.SWISS_FRANK;
Double secondRate = CurrencyExchange.MALAYSIAN_RINGGIT;
Double money = (double)107446.81;
Double expectedAmount = (double)475531.92;

Double actualAmount = currencyRateConversion(firstRate, secondRate, money);

Assert.assertEquals(expectedAmount,actualAmount);
}

@Test
public void testCurrencyRateConversion9() {
//Given:
//public Double currencyRateConversion(Double firstRate, Double secondRate, Double money)
Double firstRate = CurrencyExchange.MALAYSIAN_RINGGIT;
Double secondRate = CurrencyExchange.JAPANESE_YEN;
Double money = (double)475531.92;
Double expectedAmount = (double)12323404.39;

Double actualAmount = currencyRateConversion(firstRate, secondRate, money);

Assert.assertEquals(expectedAmount,actualAmount);
}

@Test
public void testCurrencyRateConversion10() {
//Given:
//public Double currencyRateConversion(Double firstRate, Double secondRate, Double money)
Double firstRate = CurrencyExchange.JAPANESE_YEN;
Double secondRate = CurrencyExchange.CHINESE_YUAN_RENMINBI;
Double money = (double)12323404.39;
Double expectedAmount = (double)736170.22;

Double actualAmount = currencyRateConversion(firstRate, secondRate, money);

Assert.assertEquals(expectedAmount,actualAmount);
}

}
Empty file removed src/test/java/DELETEME
Empty file.
Binary file not shown.
Binary file added target/test-classes/CurrencyExchangeTest.class
Binary file not shown.