-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
169 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
|
||
public class FOREX { | ||
public final double startingUSDollars = 6500; | ||
public double cash; | ||
public double eurosSpent = 2163.76; | ||
public final double euroToUSDRate = 1.0535; | ||
public final double yenToUSDRate = 0.0091; | ||
public final double rupeeToUSDRate = 0.0136; | ||
public double yenSpent = 156000; | ||
public double rupeeSpent = 100000; | ||
|
||
public FOREX() { | ||
cash = startingUSDollars; | ||
} | ||
|
||
public double convertToUSD(double amount, double exchangeRate) { | ||
return amount * exchangeRate; | ||
} | ||
|
||
public static void main(String[] args) { | ||
FOREX forex = new FOREX(); | ||
System.out.println("--------------------------------------------------"); | ||
System.out.println( | ||
"This Program Converts an amount of money" + | ||
"\nfrom a specific country into the equivalent" + | ||
"\ncurrency of another country give the current" + | ||
"\nexchange rate"); | ||
|
||
// Euros | ||
System.out.println("--------------------------------------------------"); | ||
System.out.println("\nStarting US Dollars:\t\t\t" + forex.cash); | ||
System.out.println("\nEurope:"); | ||
System.out.println("\tEuros Spent:\t\t\t" + forex.eurosSpent); | ||
System.out.println("\tUS Dollars Equivalent:\t\t" + forex.convertToUSD(forex.eurosSpent, forex.euroToUSDRate)); | ||
forex.cash -= forex.convertToUSD(forex.eurosSpent, forex.euroToUSDRate); | ||
System.out.println("\tUS Dollars Remaining:\t\t" + forex.cash); | ||
// Yen | ||
System.out.println("\nJapan:"); | ||
System.out.println("\tYen Spent:\t\t\t" + forex.yenSpent); | ||
System.out.println("\tUS Dollars Equivalent:\t\t" + forex.convertToUSD(forex.yenSpent, forex.yenToUSDRate)); | ||
forex.cash -= forex.convertToUSD(forex.yenSpent, forex.yenToUSDRate); | ||
System.out.println("\tUS Dollars Remaining:\t\t" + forex.cash); | ||
// Rupees | ||
System.out.println("\nIndia:"); | ||
System.out.println("\tRupees Spent:\t\t\t" + forex.rupeeSpent); | ||
System.out.println( "\tUS Dollars Equivalent:\t\t" + forex.convertToUSD(forex.rupeeSpent, forex.rupeeToUSDRate)); | ||
forex.cash -= forex.convertToUSD(forex.rupeeSpent, forex.rupeeToUSDRate); | ||
// Calculating and displaying remaining money | ||
System.out.println("\tUS Dollars Remaining:\t\t" + forex.cash); | ||
System.out.println("--------------------------------------------------"); | ||
System.out.println("Remaining US Dollars:\t\t\t" + forex.cash); | ||
// Calculating souvenir purchases | ||
System.out.println("\n\n--------------------------------------------------"); | ||
System.out.println("Souvenir Purchases"); | ||
System.out.println("\t(all values in US Dollars)"); | ||
System.out.println("--------------------------------------------------"); | ||
System.out.println("Item 1"); | ||
System.out.println("\tCost Per Item:\t\t\t$12.99"); | ||
System.out.println("\tBudget:\t\t\t\t$100.00"); | ||
System.out.println("Total Items Purchased:\t\t\t" + (int) (100 / 12.99)); | ||
System.out.println("Funds Remaining:\t\t\t$" + (int) (100 % 12.99)); | ||
|
||
System.out.println("\nItem 2"); | ||
System.out.println("\tCost Per Item:\t\t\t$29.99"); | ||
System.out.println("\tBudget:\t\t\t\t$300.00"); | ||
System.out.println("Total Items Purchased:\t\t\t" + (int) (300 / 29.99)); | ||
System.out.println("Funds Remaining:\t\t\t$" + (int) (300 % 29.99)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import java.util.InputMismatchException; | ||
import java.util.NoSuchElementException; | ||
import java.util.Scanner; | ||
|
||
public class inoutOutputActual { | ||
double num1, num2; | ||
|
||
public inoutOutputActual(double num1, double num2) { | ||
this.num1 = num1; | ||
this.num2 = num2; | ||
} | ||
|
||
double sum() {return num1 + num2;} | ||
|
||
double difference() {return num1 - num2;} | ||
|
||
double product() {return num1 * num2;} | ||
|
||
double average() {return sum() / 2;} | ||
|
||
double quotient() {return num1 / num2;} | ||
|
||
double modDiv() {return num1 % num2;} | ||
public static void main(String... args) { | ||
Scanner scanner = new Scanner(System.in); | ||
double num1, num2; | ||
num1 = 0; | ||
num2 = 0; | ||
|
||
System.out.print("First Number: "); | ||
try { | ||
num1 = scanner.nextDouble(); | ||
} catch (InputMismatchException e) { | ||
System.out.println("inoutOutputActual.main()"); | ||
} catch (NoSuchElementException e) { | ||
System.out.println("inoutOutputActual.main()"); | ||
} catch (IllegalStateException e) { | ||
System.out.println("inoutOutputActual.main()"); | ||
} | ||
|
||
System.out.print("Second Number: "); | ||
try { | ||
num2 = scanner.nextDouble(); | ||
} catch (InputMismatchException e) { | ||
System.out.println("inoutOutputActual.main()"); | ||
} catch (NoSuchElementException e) { | ||
System.out.println("inoutOutputActual.main()"); | ||
} catch (IllegalStateException e) { | ||
System.out.println("inoutOutputActual.main()"); | ||
} | ||
|
||
inoutOutputActual instance = new inoutOutputActual(num1, num2); | ||
|
||
System.out.println("Sum: " + instance.sum()); | ||
System.out.println("Difference: " + instance.difference()); | ||
System.out.println("Product: " + instance.product()); | ||
System.out.println("Average: " + instance.average()); | ||
System.out.println("Quotient: " + instance.quotient()); | ||
System.out.println("Modulus Division: " + instance.modDiv()); | ||
|
||
scanner.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
public class mathMethodsDemo { | ||
public static void main(String[] args) { | ||
// double number = 2; | ||
// double nthPower = 15; | ||
// double powValue = Math.pow(number, nthPower); | ||
// System.out.println(number + " to the power of " + nthPower + ": " + powValue); | ||
|
||
// int n = 2; | ||
// int p = 15; | ||
// int powValue2 = (int) Math.pow(n, p); | ||
// System.out.println(n + " to the power of " + p + ": " + powValue2); | ||
// System.out.println(); | ||
|
||
// double someNumber = 16; | ||
// double squareRoot = Math.sqrt(someNumber); | ||
// System.out.println("The square root of " + someNumber + " is: " + squareRoot); | ||
|
||
// int integerNumber = -34; | ||
// int absoluteValue = Math.abs(integerNumber); | ||
// System.out.println("The absolute value of " + integerNumber + " is: " + absoluteValue); | ||
// System.out.println(); | ||
|
||
// double decimalNumber = -4.56; | ||
// double decimalAbsValue = Math.abs(decimalNumber); | ||
// System.out.println("The absolute value of " + decimalNumber + " is: " + decimalAbsValue); | ||
// System.out.println(); | ||
|
||
// double myRadius = 3.5; | ||
// double myCircumfrence = 2 * Math.PI * myRadius; | ||
// System.out.println("The circumfrence of a circle with a radius of " + myRadius + " is: " + myCircumfrence); | ||
|
||
// int randNumber = (int) (Math.random() * 5); | ||
// System.out.println("A random number between 0 and 5: " + randNumber); | ||
|
||
System.out.println(Math.random()); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.