Coders Packet

EasyExchange using Java

By Ayush Gupta

The EasyExchange project is an efficient and user-friendly currency conversion application that enables users to convert amounts between different currencies seamlessly.

With a well-designed architecture, the Java Currency Converter provides precise and reliable currency conversion. The user interface is intuitive, allowing users to select source and target currencies, enter the amount, and obtain instant and accurate conversion results.

Menu Display:

  • The program starts by displaying a menu with three currency options: 1 for Rupees, 2 for Dollars, and 3 for Euros.

User Input:

  • The program uses the Scanner class to take user input for the currency choice (an integer) and the amount to be converted (a double).

Conversion Logic:

  • Depending on the user's choice (1 for Rupees, 2 for Dollars, or 3 for Euros), the program calls one of the three conversion methods: Ruppe_to_other, Dollar_to_other, or Euro_to_other.

Conversion Methods:

  • Ruppe_to_other(double amt): This method is called when the user selects Rupees (choice 1). It displays conversion rates between Rupees, Dollars, and Euros and calculates the converted amounts based on the user-provided amount.

  • Dollar_to_other(double amt): This method is called when the user selects Dollars (choice 2). It displays conversion rates between Dollars, Rupees, and Euros and calculates the converted amounts based on the user-provided amount.

  • Euro_to_other(double amt): This method is called when the user selects Euros (choice 3). It displays conversion rates between Euros, Rupees, and Dollars and calculates the converted amounts based on the user-provided amount.

Conversion Formulas:

  • The conversion formulas are hardcoded within each conversion method based on the exchange rates specified in the code. For example, to convert Rupees to Dollars, it multiplies the amount in Rupees by the conversion rate.

Output:

  • The program displays the conversion rates and the converted amounts in the selected currencies.
import java. util.Scanner;
public class CurrencyConverter {

    public static void main(String[] args) {
        System.out.println("1 Ruppe");
        System.out.println("2 Dollar");
        System.out.println("3 Euro");
        // take input
        Scanner sc = new Scanner(System.in);
        System. out.println("Choose the currency");
        int choice = sc.nextInt();
        System.out.println("Enter the amount");
        double amount = sc.nextDouble();
        // convert the amount
        switch (choice) {
            case 1:
                Ruppe_to_other(amount);
                break;
            case 2:
                Dollar_to_other(amount);
                break;
            case 3:
                Euro_to_other(amount);
                break;
            default:
                System.out.println("Invalid choice");
        }

    }

    public static void Ruppe_to_other(double amt) {
        System.out.println("1 Ruppe = " + 0.013 + " Dollar");
        System.out.println();

        System.out.println(amt+" Ruppe = " + (amt*0.013) + " Dollar");
        System.out.println();

        System.out.println("1 Ruppe = " + 0.012 + " Euro");
        System.out.println();
        System.out.println(amt+" Ruppe = " + (amt*0.012) + " Euro");
        System.out.println();

    }


    public static void Dollar_to_other(double amt) {
        System.out.println("1 Dollar = " + 79.37 + " Ruppe");
        System.out.println();
        System.out.println(amt+" Dollar = " + (amt*79.37) + " Ruppe");
        System.out.println();

        System.out.println("1 Dollar= " + 0.98 + " Euro");
        System.out.println();

        System.out.println(amt+" Dollar = " + (amt*0.98) + " Euro");
    }



    public static void Euro_to_other(double amt){
        System.out.println("1 Euro = " + 80.85 + " Ruppe");
        System.out.println();
        System.out.println(amt+" Euro = " + (amt*80.85) + " Ruppe");
        System.out.println();

        System.out.println("1 Euro = " + 1.02 + " Dollar");
        System.out.println();

        System.out.println(amt+" Euro = " + (amt*1.02) + " Dollar");
   }
}

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by Ayush Gupta (Ayush07)

Download packets of source code on Coders Packet