# Field Manual for Hackers

## Java code to Convert currency: Ex. Dollar into rupee

1. import java.util.Scanner;

class Test{

public static void main(String ar[])
{

float a;
double b;
int o;
Scanner sc=new Scanner(System.in);
System.out.println("Enter Amount");
a=sc.nextFloat();
System.out.println("Select Option");
System.out.println("1.INR to USD");
System.out.println("2.USD to INR");
o=sc.nextInt();

if(o==1){b=a/67.52; System.out.println("Rs. "+b);}
else if(o==2){b=a*67.52; System.out.println(b+"\$");}
else {System.out.println("Wrong Input");}

}
}

2. import java.util.Scanner;
class Dollorconverter
{
public static void main(String ar[])
{
Scanner sc=new Scanner(System.in);
double Dollor,Total;
System.out.println("Enter the value of Dollor");
Dollor=sc.nextInt();
Total=Dollor*67.55;
System.out.println("Dollor to rupee"+Total);

}
}

3. import java.util.Scanner;
class Currency
{
public static void main(String Args[])
{
int i;
double dl,rs;
System.out.println("select the currency");
System.out.println("press 1 to convert in dollars ");
System.out.println("press 2 to cnvert in rupees");
Scanner sc=new Scanner(System.in);
i=sc.nextInt();
if(i==1)
{
System.out.println("enter the amount in INR");
rs=sc.nextDouble();
dl=rs*0.015;
System.out.println("amount in USD is"+dl);
}
else if(i==2)
{
System.out.println("enter the amount in USD");
dl=sc.nextDouble();
rs=dl*67.98;
System.out.println("amount in INR is"+rs);
}
else
{
System.out.println("wrong choice");
}
}
}

4. import java.util.Scanner;

class Currency
{
public static void main(String ar[])
{
Float r,d,c;
System.out.println("Enter choice\n 1 for dollar to rupee\n 2 for rupee to dollar");
Scanner o=new Scanner(System.in);
c=o.nextFloat();
if(c==1)
{
System.out.print("Enter amount in dollar: ");
d=o.nextFloat();
r=d*68;
System.out.println("Amount in rupees is: "+r);
}
else if(c==2)
{
System.out.print("Enter amount in rupees: ");
r=o.nextFloat();
d=r/68;
System.out.println("Amount in rupees is: "+d);
}
else
System.out.println("Wrong choice");
}
}

5. import java.util.Scanner;

class currency
{
public static void main(String ar[])
{
Scanner conv = new Scanner(System.in);
double dollar,rupee;
double ch;
System.out.println("1.select '1' for conversion from dollar to rupee");
System.out.println("2.select '2' for conversion from rupee to dollar");
ch = conv.nextDouble();

if(ch==1)
{
System.out.println("conversion from dollar to rupee");
System.out.println("enter dollar currency");
dollar = conv.nextDouble();
System.out.println(" the rupee currency : " +dollar*68.52);

}
else
if(ch==2)
{
System.out.println("conversion from rupee to dollar currency");
System.out.println("enter the rupee currency");
rupee = conv.nextDouble();
System.out.println("the dollar currency : " +rupee/68.52);

}
else
System.out.println("wrng choice entered");
}

}

6. This comment has been removed by the author.

7. import java.util.Scanner;
public class Dollar
{
public static void main(String args[])
{
float rupee,dollar;
System.out.println("Enter number");
Scanner sc=new Scanner(System.in);
dollar=sc.nextFloat();
rupee=(dollar*73.81f);
System.out.println(rupee);
}
}

8. import java.util.Scanner;
class Convert{
public static void main(String ar[]){
Scanner obj=new Scanner(System.in);
double dollar,rupee;
System.out.println("enter the amount of money in dollar");
dollar=obj.nextFloat();
rupee=dollar*69.54;
System.out.println("the amount in rupees is"+rupee);
}

}

9. class Dollar{
public static void main(String ar[]){
Double r;
Double d=Double.parseDouble(ar[0]);
r=d*69.49;
System.out.printf("Dollar in rupees="+r);
}
}

10. package com.example.myapplication;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class DollarToRupees extends Activity {

int Dollar,Rupees,D= (int) 69.58;
Button btDtoR;
EditText etDtoR;
TextView tvDtoR;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dollar_to_rupees);

btDtoR=findViewById(R.id.btDtoR);
tvDtoR=findViewById(R.id.tvDtoR);
etDtoR=findViewById(R.id.etDtoR);

btDtoR.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Dollar=Integer.parseInt(etDtoR.getText().toString());

Rupees=Dollar*D;

tvDtoR.setText("Rupees="+Rupees);
}
});
}
}