// Arup Guha
// 7/7/03
// BHCSI Introduction to Java Program #1 Solution
// Brief Description: This program takes in information about how much 
//                    money they have in US dollars, the foreign 
//                    exchange rate, and how much of that foreign money
//                    was spent to calculate how much money the user will
//                    have left after a trip to a foreign country.
import java.io.*;

public class Money {


  public static void main(String[] args) throws IOException {

    BufferedReader stdin = new BufferedReader(
				new InputStreamReader(System.in));

    // Declare necessary variables to read in user input.
    double dollars, rate;
    double spent;

    // Read in user input.
    System.out.println("How many US dollars are you exchanging?");
    dollars = (Double.valueOf(stdin.readLine())).doubleValue(); 

    System.out.println("What is the exchange rate from US dollars to the foreign currency?");  
    rate = (Double.valueOf(stdin.readLine())).doubleValue(); 

    System.out.println("How much foreign currency did you spend?");
    spent = (Double.valueOf(stdin.readLine())).doubleValue(); 

    // Charge transaction fee and convert money.
    dollars = dollars - 2;
    double foreign = dollars*rate;
  
    // Spend money.
    foreign = foreign - spent;

    // Convert money back to dollars and charge transaction fee.
    double money_left = foreign/rate;
    money_left = money_left - 2;

    // Output money left.
    System.out.println("You will be left with $"+money_left+" US currency.");
  }
}
