Click here to Skip to main content
15,881,967 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
example java program for currency convertor in simple method using functions

What I have tried:

import java.util.Scanner;
class coin{
	public  void 
		coin obj=new coin();
		Scanner sc=new Scanner(;
		System.out.println("Welcome to currency convertor");
		System.out.println("enter your amount");
		int num=sc.nextInt();
		System.out.println("1 for canadian dollar to Indian rupees");
		System.out.println("2 for American dollar to Indian rupees"); 
		int choice=sc.nextInt();
			case 1:{
			case 2:{
	public void iscanadiandollartoIndianrupees(int num){
		Scanner amt=new Scanner(;
		int coverting=0;
		int num1=amt.nextInt;
		double canadian=62.74;
		double converting=num1*canadian;
	void isamericandollartoIndianrupees(int num){
		Scanner dol=new Scanner(;
		int covert=0;
		int dol=amt.nextInt;
		double canadian=83.17;
		double converting=dol*convert;

Updated 19-Jan-24 5:44am
CHill60 19-Jan-24 11:44am    
You've forgotten to ask a question
OriginalGriff 19-Jan-24 12:06pm    
What does it do that you didn't expect, or not do that you did?
What have you tried to do to find out why?
Are there any error messages, and if so, where and when? What did you do to make them happen?

This is not a good question - we cannot work out from that little what you are having problems with.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
Use the "Improve question" widget to edit your question and provide better information.
Richard MacCutchan 19-Jan-24 12:30pm    
Lots of simple errors which you can easily correct by reading the code. You are also missing a main method, so I doubt this will even compile.
[no name] 19-Jan-24 12:50pm    
You should be using "codes" / dictionaries for context; not combining currency "names" with function names. How do support 100+ currencies and country codes?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900