0% found this document useful (0 votes)
22 views26 pages

Currency Converter

The document is a mini project report for a Currency Converter application developed in C as part of a programming course at SRM Institute of Science and Technology. It outlines the problem statement, methodology, coding structure, and includes a flowchart and code snippets for the application. The converter allows users to convert Indian Rupees (INR) to various currencies based on selected countries from different continents, with features for user interaction and error handling.

Uploaded by

abhishek8508408
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views26 pages

Currency Converter

The document is a mini project report for a Currency Converter application developed in C as part of a programming course at SRM Institute of Science and Technology. It outlines the problem statement, methodology, coding structure, and includes a flowchart and code snippets for the application. The converter allows users to convert Indian Rupees (INR) to various currencies based on selected countries from different continents, with features for user interaction and error handling.

Uploaded by

abhishek8508408
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

lOMoARcPSD|60310108

Currency Convertor Project FILE(up)

Programming For Problem Solving (SRM Institute of Science and Technology)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Abhishek Mishra ([email protected])
lOMoARcPSD|60310108

CURRENCY CONVERTER

21CSS101J – PROGRAMMING FOR PROBLEM-SOLVING

Mini Project Report

Submitted by

Student Name – Subhajit Mitra


RA2311003010213
B.Tech. CSE Core

SCHOOL OF COMPUTING
COLLEGE OF ENGINEERING AND TECHNOLOGY
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
(Under Section 3 of UGC Act, 1956)
S.R.M. NAGAR, KATTANKULATHUR – 603 203
CHENGALPATTU DISTRICT

November 2023

1|Page

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

BONAFIDE CERTIFICATE

Certified that Mini project report titled Currency Converter is the bonafide work of Reg.No-
RA2311003010213 Name-Subhajit Mitra who carried out the minor project under my supervision.
Certified further, that to the best of my knowledge, the work reported herein does not form any other
project report or disse6rtation on the basis of which a degree or award was conferred on an earlier
occasion on this or any other candidate.

SIGNATURE SIGNATURE

Assistant Professor Professor and Head

Department of CTECH of Department of CTECH

TABLE OF CONTENTS

2|Page

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

S No. Title Page No.

4-5
1 Problem Statement

6-7
2 Methodology / Procedure/ Algorithm
8
3 Flowchart

9-13
4 Coding (C)

14-22
5 Frontend (Python)

23
6 Results/Screenshots

24
7 Conclusion

25
8 References

Problem Statement
Problem Statement: Currency Converter Application in C

3|Page

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

You are tasked with developing a currency converter application in C that allows
users to convert an amount in Indian Rupees (INR) to the currency of a selected
country. The application should have a user-friendly interface and support
conversions for countries in different continents.

Requirements:

1.User Input:

 Prompt the user to enter the amount in INR.


 Ask the user to select the continent from the following options: Asia,
Africa, Europe, North America, South America, Oceania.

2.Country Selection:

 Based on the selected continent, present a list of countries for the user to
choose from.
 Allow the user to input the serial number corresponding to the desired
country.

3.Currency Conversion:

 Implement currency conversion logic for each country using predefined


conversion rates.
 Display the converted amount in the selected country's currency with two
decimal places.

4.Invalid Input Handling:

 Handle invalid inputs gracefully. For example, if the user enters an invalid
continent or country serial number, display an appropriate error message.

5.User Interaction:

4|Page

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

 After displaying the converted amount, ask the user if they want to perform
another conversion or end the program.
 If the user chooses to continue, allow them to input a new amount and
select a different country.

Code Structure:

 Use functions to modularize the code and improve readability.


 Implement a loop to allow the user to perform multiple conversions until
they choose to exit.

Additional Considerations:

 Ensure that the code is well-commented for clarity.


 Test the application with various inputs to validate its functionality.

5|Page

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

Methodology / Procedure/ Algorithm


Initialization:

Declare necessary variables for the program, including cont, c, country, n, and
amt.
Define arrays to store country names (contA, contE, contAf, contN, contS,
contO) and conversion rates (curA, curE, curAf, curN, curS, curO).
Set up a loop to allow continuous conversion until the user decides to exit.
User Input:

Display a welcome message to the user.


Prompt the user to enter the amount in INR (amt).
Ask the user to select the continent (cont) by entering the corresponding serial
number.

Country Selection:

Based on the selected continent, display a list of countries for the user to choose
from.
Prompt the user to input the serial number of the desired country (country).

Currency Conversion:

Implement conditional statements (if, else if) to determine the selected continent
and perform the currency conversion accordingly.
Use the selected country serial number to access the corresponding conversion
rate from the arrays.
Calculate the converted amount (inr) by multiplying the input amount (amt) with
the respective conversion rate.

Display Result:

Print the converted amount in the selected country's currency with two decimal
places.

6|Page

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

Handle cases where the user provides an invalid country serial number with an
appropriate error message.

User Interaction:

Ask the user if they want to perform another conversion or end the program.
If the user chooses to continue (n == 1), repeat the process by returning to the
beginning of the loop.
If the user chooses to end the program, exit the loop.

Code Structure:

Utilize functions to encapsulate logical blocks of code, promoting readability and


maintainability.
Implement error-checking mechanisms to handle invalid inputs and guide the
user accordingly.

Testing:

Validate the application by testing it with various inputs, including valid and
invalid selections.
Ensure that the currency conversion is accurate, and the program behaves as
expected.

Documentation:

Comment the code adequately to explain the purpose of each section and aid
future modifications.
Provide a clear and concise problem statement to guide the development of the
application.

Conclusion:

Ensure the code adheres to best practices, is well-structured, and achieves the
specified requirements for a functional and user-friendly currency converter in C.
7|Page

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

FLOWCHART

Figure 1.0

8|Page

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

Coding (C/Python)
#include<stdio.h>

int cont,c=1,country,n;

float amt;

char *contA[19]={"China", "Philippines", "Japan", "Vietnam", "Thailand","Indonesia", "Malaysia", "South Korea",


"Pakistan", "Bangladesh","Nepal", "Sri Lanka", "Myanmar", "Cambodia", "Laos", "Mongolia",

"Kazakhstan", "Uzbekistan", "Turkmenistan"};

char *contE[20]={"Albania", "Andorra", "Austria", "Belgium", "Bulgaria", "Croatia","Cyprus", "Czech Republic",


"Denmark", "Estonia", "Finland", "France",

"Germany", "Greece", "Hungary", "Iceland", "Ireland", "Italy", "United Kingdom", "Lithuania"};

char *contAf[20] = {"Algeria", "Angola", "Benin", "Botswana", "Cameroon", "Chad", "Egypt", "Ethiopia", "Ghana",
"Ivory Coast", "Kenya", "Libya", "Madagascar", "Morocco", "Nigeria", "Senegal", "South Africa", "Tanzania",
"Uganda", "Zimbabwe"};

char *contN[20] = {"United States", "Canada", "Mexico", "Guatemala", "Honduras", "El Salvador", "Nicaragua",
"Costa Rica", "Panama", "Belize", "Jamaica", "Haiti", "Dominican Republic", "Cuba", "Trinidad and Tobago",
"Barbados", "Bahamas", "Honduras", "Cayman Islands","Puerto Rico"};

char *contS[20] = {"Brazil", "Argentina", "Colombia", "Venezuela", "Aruba","Caribbean Netherlands","Chile",


"Ecuador", "Bolivia", "Paraguay", "Uruguay", "Guyana", "Suriname", "French Guiana", "Falkland Islands",
"Guyana", "Suriname", "French Guiana", "Falkland Islands"};

char *contO[20] = {"Australia", "New Zealand", "Papua New Guinea", "Fiji", "Solomon Islands", "Vanuatu", "New
Caledonia", "French Polynesia", "Samoa", "American Samoa", "Tonga", "Tuvalu", "Kiribati", "Marshall Islands",
"Nauru", "Palau", "Micronesia", "Federated States of Micronesia", "Guam", "Northern Mariana Islands"};

float
curA[19]={0.084,0.67,1.72,325.42,2.36,188.27,0.94,10.68,2.69,1.27,1.63,2.69,0.62,50.96,0.02,0.21,0.21,0.02,0.1
7};

float curE[20]={0.087, 0.014, 0.014, 0.014, 0.032, 0.13, 0.014, 0.18, 0.11, 0.014, 0.014, 0.014, 0.014, 0.014,
0.056, 0.92, 0.014, 0.014, 0.011, 0.014};

float curAf[20]={12.83, 11.40, 11.82, 11.02, 11.45, 11.09, 10.15, 11.88, 11.45, 11.45, 11.66, 11.41, 11.01, 11.01,
10.65, 11.09, 11.01, 10.91, 11.22, 10.75};

float curN[20]={80.45, 74.17, 23.21, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82,
11.82, 11.82, 11.82, 11.82, 11.82, 11.82};

float curS[20]={11.59, 11.84, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59,
11.59, 11.59, 11.59, 11.59, 11.59, 11.59};

float curO[20]={70.59, 73.54, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82,
11.82, 11.82, 11.82, 11.82, 11.82, 11.82};

int main()

for(;;){
9|Page

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

printf("WELCOME TO CURRENCY CONVERTOR\nEnter the number in INR\n");

scanf("%f",&amt);

printf("Enter the serial number coresponding to the continent in which the continent exist\n1) Asia\n2)
Africa\n3) Europe\n4) North America\n5) South America\n6) Oceania\n");

scanf("%d",&cont);

if(cont==1){

printf("Enter the country's serial number\n");

for(int i=0;i<19;i++){

printf("%d) %s\n",c,contA[i]);

c++;

c=1;

scanf("%d",&country);

if(country<=19)

country=country-1;

float inr=amt*curA[country];

printf("The amount in %s's currency would be %0.2f\n",contA[country],inr);

else

printf("Invalid input\n");

else if(cont==2){

printf("Enter the country's serial number\n");

for(int i=0;i<20;i++){

printf("%d) %s\n",c,contAf[i]);

c++;

c=1;

scanf("%d",&country);

if(country<=20){

country=country-1;
10 | P a g e

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

float inr1=amt*curAf[country];

printf("The amount in %s's currency would be %0.2f\n",contAf[country],inr1);

else

printf("Invalid input\n");

else if(cont==3){

printf("Enter the country's serial number\n");

for(int i=0;i<20;i++){

printf("%d) %s\n",c,contE[i]);

c++;

c=1;

scanf("%d",&country);

if(country<=20){

country=country-1;

float inr2=amt*curE[country];

printf("The amount in %s's currency would be %0.2f\n",contE[country],inr2);

else

printf("Invalid Input\n");

else if(cont==4){

printf("Enter the country's serial number\n");

for(int i=0;i<20;i++){

printf("%d) %s\n",c,contN[i]);

c++;

c=1;

scanf("%d",&country);

if(country<=20){

country=country-1;

11 | P a g e

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

float inr3=amt*curN[country];

printf("The amount in %s's currency would be %0.2f\n",contN[country],inr3);}

else

printf("Invalid Input\n");

else if(cont==5){

printf("Enter the country's serial number\n");

for(int i=0;i<20;i++){

printf("%d) %s\n",c,contS[i]);

c++;

c=1;

scanf("%d",&country);

if(country<=20){

country=country-1;

float inr4=amt*curS[country];

printf("The amount in %s's currency would be %0.2f\n",contS[country],inr4);}

else

printf("Invalid Input\n");

else if(cont==6){

printf("Enter the country's serial number\n");

for(int i=0;i<20;i++){

printf("%d) %s\n",c,contO[i]);

c++;

c=1;

scanf("%d",&country);

if(country<=20){

country=country-1;

float inr5=amt*curO[country];

printf("The amount in %s's currency would be %0.2f\n",contO[country],inr5);

12 | P a g e

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

else

printf("Invalid Input\n");

else

printf("Sorry wrong input\n");

printf("Do you want to convert more or end it here\nEnter 1 if yes\n");

scanf("%d",&n);

if(n==1){

continue;

else {

break;}

return 0;

13 | P a g e

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

Frontend(Python)
(Index.py)
cont = 1

c=1

country = 0

n=0

amt = 0.0

contA = ["China", "Philippines", "Japan", "Vietnam", "Thailand", "Indonesia", "Malaysia", "South Korea",
"Pakistan", "Bangladesh", "Nepal", "Sri Lanka", "Myanmar", "Cambodia", "Laos", "Mongolia", "Kazakhstan",
"Uzbekistan", "Turkmenistan"]

contE = ["Albania", "Andorra", "Austria", "Belgium", "Bulgaria", "Croatia", "Cyprus", "Czech Republic",
"Denmark", "Estonia", "Finland", "France", "Germany", "Greece", "Hungary", "Iceland", "Ireland", "Italy", "United
Kingdom", "Lithuania"]

contAf = ["Algeria", "Angola", "Benin", "Botswana", "Cameroon", "Chad", "Egypt", "Ethiopia", "Ghana", "Ivory
Coast", "Kenya", "Libya", "Madagascar", "Morocco", "Nigeria", "Senegal", "South Africa", "Tanzania", "Uganda",
"Zimbabwe"]

contN = ["United States", "Canada", "Mexico", "Guatemala", "Honduras", "El Salvador", "Nicaragua", "Costa Rica",
"Panama", "Belize", "Jamaica", "Haiti", "Dominican Republic", "Cuba", "Trinidad and Tobago", "Barbados",
"Bahamas", "Honduras", "Cayman Islands", "Puerto Rico"]

contS = ["Brazil", "Argentina", "Colombia", "Venezuela", "Aruba", "Caribbean Netherlands", "Chile", "Ecuador",
"Bolivia", "Paraguay", "Uruguay", "Guyana", "Suriname", "French Guiana", "Falkland Islands", "Guyana",
"Suriname", "French Guiana", "Falkland Islands", "Peru"]

contO = ["Australia", "New Zealand", "Papua New Guinea", "Fiji", "Solomon Islands", "Vanuatu", "New
Caledonia", "French Polynesia", "Samoa", "American Samoa", "Tonga", "Tuvalu", "Kiribati", "Marshall Islands",
"Nauru", "Palau", "Micronesia", "Federated States of Micronesia", "Guam", "Northern Mariana Islands"]

curA = [0.084, 0.67, 1.72, 325.42, 2.36, 188.27, 0.94, 10.68, 2.69, 1.27, 1.63, 2.69, 0.62, 50.96, 0.02, 0.21, 0.21,
0.02, 0.17]

curE = [0.087, 0.014, 0.014, 0.014, 0.032, 0.13, 0.014, 0.18, 0.11, 0.014, 0.014, 0.014, 0.014, 0.014, 0.056, 0.92,
0.014, 0.014, 0.011, 0.014]

curAf = [12.83, 11.40, 11.82, 11.02, 11.45, 11.09, 10.15, 11.88, 11.45, 11.45, 11.66, 11.41, 11.01, 11.01, 10.65,
11.09, 11.01, 10.91, 11.22, 10.75]

curN = [80.45, 74.17, 23.21, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82,
11.82, 11.82, 11.82, 11.82, 11.82]

curS = [11.59, 11.84, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59,
11.59, 11.59, 11.59, 11.59, 11.59]

curO = [70.59, 73.54, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82,
11.82, 11.82, 11.82, 11.82, 11.82]
14 | P a g e

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

while True:

print("WELCOME TO CURRENCY CONVERTOR")

amt = float(input("Enter the number in INR\n"))

cont = int(input("Enter the serial number corresponding to the continent in which the country exists\n1)
Asia\n2) Africa\n3) Europe\n4) North America\n5) South America\n6) Oceania\n"))

if cont == 1:

print("Enter the country's serial number")

for i in range(19):

print(f"{c}) {contA[i]}")

c += 1

c=1

country = int(input())

if country <= 19:

country -= 1

inr = amt * curA[country]

print(f"The amount in {contA[country]}'s currency would be {inr:.2f}")

else:

print("Invalid input")

elif cont == 2:

print("Enter the country's serial number")

for i in range(20):

print(f"{c}) {contAf[i]}")

c += 1

c=1

country = int(input())

if country <= 20:

country -= 1

inr1 = amt * curAf[country]

15 | P a g e

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

print(f"The amount in {contAf[country]}'s currency would be {inr1:.2f}")

else:

print("Invalid input")

elif cont == 3:

print("Enter the country's serial number")

for i in range(20):

print(f"{c}) {contE[i]}")

c += 1

c=1

country = int(input())

if country <= 20:

country -= 1

inr2 = amt * curE[country]

print(f"The amount in {contE[country]}'s currency would be {inr2:.2f}")

else:

print("Invalid input")

elif cont == 4:

print("Enter the country's serial number")

for i in range(20):

print(f"{c}) {contN[i]}")

c += 1

c=1

country = int(input())

if country <= 20:

country -= 1

inr3 = amt * curN[country]

print(f"The amount in {contN[country]}'s currency would be {inr3:.2f}")

else:

print("Invalid input")

elif cont == 5:

16 | P a g e

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

print("Enter the country's serial number")

for i in range(20):

print(f"{c}) {contS[i]}")

c += 1

c=1

country = int(input())

if country <= 20:

country -= 1

inr4 = amt * curS[country]

print(f"The amount in {contS[country]}'s currency would be {inr4:.2f}")

else:

print("Invalid input")

elif cont == 6:

print("Enter the country's serial number")

for i in range(20):

print(f"{c}) {contO[i]}")

c += 1

c=1

country = int(input())

if country <= 20:

country -= 1

inr5 = amt * curO[country]

print(f"The amount in {contO[country]}'s currency would be {inr5:.2f}")

else:

print("Invalid input")

else:

print("Sorry wrong input")

n = int(input("Do you want to convert more or end it here?\nEnter 1 if yes\n"))

if n == 1:

17 | P a g e

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

continue

else:

break

(GUI.py)
import tkinter as tk

from tkinter import ttk

contA = ["China", "Philippines", "Japan", "Vietnam", "Thailand", "Indonesia", "Malaysia", "South Korea",
"Pakistan", "Bangladesh", "Nepal", "Sri Lanka", "Myanmar", "Cambodia", "Laos", "Mongolia",
"Kazakhstan", "Uzbekistan", "Turkmenistan"]

contE = ["Albania", "Andorra", "Austria", "Belgium", "Bulgaria", "Croatia", "Cyprus", "Czech Republic",
"Denmark", "Estonia", "Finland", "France", "Germany", "Greece", "Hungary", "Iceland", "Ireland",
"Italy", "United Kingdom", "Lithuania"]

contAf = ["Algeria", "Angola", "Benin", "Botswana", "Cameroon", "Chad", "Egypt", "Ethiopia", "Ghana",
"Ivory Coast", "Kenya", "Libya", "Madagascar", "Morocco", "Nigeria", "Senegal", "South Africa",
"Tanzania", "Uganda", "Zimbabwe"]

contN = ["United States", "Canada", "Mexico", "Guatemala", "Honduras", "El Salvador", "Nicaragua",
"Costa Rica", "Panama", "Belize", "Jamaica", "Haiti", "Dominican Republic", "Cuba", "Trinidad and
Tobago", "Barbados", "Bahamas", "Honduras", "Cayman Islands", "Puerto Rico"]

contS = ["Brazil", "Argentina", "Colombia", "Venezuela", "Aruba", "Caribbean Netherlands", "Chile",


"Ecuador", "Bolivia", "Paraguay", "Uruguay", "Guyana", "Suriname", "French Guiana", "Falkland
Islands", "Guyana", "Suriname", "French Guiana", "Falkland Islands", "Peru"]

contO = ["Australia", "New Zealand", "Papua New Guinea", "Fiji", "Solomon Islands", "Vanuatu", "New
Caledonia", "French Polynesia", "Samoa", "American Samoa", "Tonga", "Tuvalu", "Kiribati", "Marshall
Islands", "Nauru", "Palau", "Micronesia", "Federated States of Micronesia", "Guam", "Northern Mariana
Islands"]

curA = [0.084, 0.67, 1.72, 325.42, 2.36, 188.27, 0.94, 10.68, 2.69, 1.27, 1.63, 2.69, 0.62, 50.96, 0.02,
0.21, 0.21, 0.02, 0.17]

curE = [0.087, 0.014, 0.014, 0.014, 0.032, 0.13, 0.014, 0.18, 0.11, 0.014, 0.014, 0.014, 0.014, 0.014,
0.056, 0.92, 0.014, 0.014, 0.011, 0.014]

curAf = [12.83, 11.40, 11.82, 11.02, 11.45, 11.09, 10.15, 11.88, 11.45, 11.45, 11.66, 11.41, 11.01, 11.01,
10.65, 11.09, 11.01, 10.91, 11.22, 10.75]

18 | P a g e

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

curN = [80.45, 74.17, 23.21, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82,
11.82, 11.82, 11.82, 11.82, 11.82, 11.82]

curS = [11.59, 11.84, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59, 11.59,
11.59, 11.59, 11.59, 11.59, 11.59, 11.59]

curO = [70.59, 73.54, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82, 11.82,
11.82, 11.82, 11.82, 11.82, 11.82, 11.82]

def convert_currency():

try:

amt = float(entry_amount.get())

cont = var_continent.get()

country = var_country.get()

# Determine the conversion rate based on the selected continent and country

if cont == "Asia":

conversion_rate = curA[contA.index(country)]

elif cont == "Africa":

conversion_rate = curAf[contAf.index(country)]

elif cont == "Europe":

conversion_rate = curE[contE.index(country)]

elif cont == "North America":

conversion_rate = curN[contN.index(country)]

elif cont == "South America":

conversion_rate = curS[contS.index(country)]

elif cont == "Oceania":

conversion_rate = curO[contO.index(country)]

converted_amount = amt * conversion_rate

19 | P a g e

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

result_label.config(text=f"The amount in {cont} - {country}'s currency would be


{converted_amount:.2f}")

except ValueError:

result_label.config(text="Invalid input. Please enter valid numbers.")

# Create the main window

root = tk.Tk()

root.title("Currency Converter")

# Create and place widgets

frame = ttk.Frame(root, padding="10")

frame.grid(row=0, column=0, sticky=(tk.W, tk.E, tk.N, tk.S))

label_amount = ttk.Label(frame, text="Enter the number in INR:")

label_amount.grid(row=0, column=0, sticky=tk.W, pady=5)

entry_amount = ttk.Entry(frame)

entry_amount.grid(row=0, column=1, pady=5)

label_continent = ttk.Label(frame, text="Select the continent:")

label_continent.grid(row=1, column=0, sticky=tk.W, pady=5)

var_continent = tk.StringVar()

combobox_continent = ttk.Combobox(frame, textvariable=var_continent, values=["Asia", "Africa",


"Europe", "North America", "South America", "Oceania"])

combobox_continent.grid(row=1, column=1, pady=5)

label_country = ttk.Label(frame, text="Select the country:")

label_country.grid(row=2, column=0, sticky=tk.W, pady=5)

20 | P a g e

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

var_country = tk.StringVar()

# Set the initial values for the country based on the selected continent

combobox_country = ttk.Combobox(frame, textvariable=var_country, values=contA)

combobox_country.grid(row=2, column=1, pady=5)

button_convert = ttk.Button(frame, text="Convert", command=convert_currency)

button_convert.grid(row=3, column=0, columnspan=2, pady=10)

result_label = ttk.Label(frame, text="")

result_label.grid(row=4, column=0, columnspan=2, pady=5)

# Event handling to update the country options based on the selected continent

def update_country_options(event):

selected_continent = var_continent.get()

if selected_continent == "Asia":

combobox_country["values"] = contA

elif selected_continent == "Africa":

combobox_country["values"] = contAf

elif selected_continent == "Europe":

combobox_country["values"] = contE

elif selected_continent == "North America":

combobox_country["values"] = contN

elif selected_continent == "South America":

combobox_country["values"] = contS

elif selected_continent == "Oceania":

combobox_country["values"] = contO

# Bind the event handler to the continent selection

21 | P a g e

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

combobox_continent.bind("<<ComboboxSelected>>", update_country_options)

# Run the Tkinter event loop

root.mainloop()

22 | P a g e

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

Results/Screenshots
This shows the interface of the
Currency Converter

Fig 2.0

This shows the drop-down


menu for continents

Fig 2.1

This
shows
the drop-down menu for the
countries present in the selected
continent

Fig 2.2

23 | P a g e

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

Conclusion

In summary, the provided C code encapsulates a currency converter program that


employs a logical flow to guide users through the process of converting amounts
from Indian Rupees (INR) to various global currencies. The program
incorporates input validation, ensuring a user-friendly experience by prompting
users to select continents and then specific countries. Utilizing predefined
currency conversion rates, the code calculates and displays the equivalent amount
in the chosen country's currency. Noteworthy is the incorporation of loops,
allowing for the possibility of multiple conversions.

It's important to mention that the program has been enhanced with a graphical
user interface (GUI) using Tkinter, a Python library. This addition elevates the
user experience by providing a visual representation of the currency converter.
The Tkinter GUI likely includes input fields, dropdown menus for continent and
country selection, and output displays for presenting the converted amounts. The
AI flow chart generator for this code would visually map out these logical
pathways and user interactions, providing a comprehensive illustration of the
program's functionality and decision points. This currency converter, with its
combination of robust logic and an intuitive GUI, not only underscores adept
programming skills but also emphasizes the significance of thoughtful design in
creating impactful software applications.

24 | P a g e

Downloaded by Abhishek Mishra ([email protected])


lOMoARcPSD|60310108

References

www.docs.python.org/3/library/tkinter.html
www.realpython.com/tkinter-python/
www.geeksforgeeks.org/python-gui-tkinter/
www.OpenAI.com
https://www.w3schools.com/c/c_arrays.php

25 | P a g e

Downloaded by Abhishek Mishra ([email protected])

You might also like