Converters

Program Code:

In Main Folder:

Main.java
import java.util.Scanner;
import converters.CurrencyConv;
import converters.DistanceConv;
import converters.TimeConv;

public class Main{

	public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int choice = 0;
		while(choice != 4){
			System.out.println("\nConverters");
			System.out.println("**********");
			System.out.println("1. Currentcy\n2. Distance\n3. Time\n4. Exit\n\nEnter Your Choice");
			choice = input.nextInt();
			switch(choice){
				case 1:CurrencyConv.userChoice();break;
				case 2:DistanceConv.userChoice();break;
				case 3:TimeConv.userChoice();break;
				case 4:break;
				default:System.out.println("Please choose valid option");
						break;
			}
		}
	}
	
}

In “converters” Folder:

TimeConv.java
package converters;

import java.util.Scanner;

public class TimeConv{
	
	public static double HrsToMins(double hrs){
		return hrs * 60;
	}
	
	public static double HrsToSecs(double hrs){
		return hrs * 60 * 60;
	}
	
	public static double MinsToHrs(double mins){
		return mins / 60;
	}
	
	public static double SecsToHrs(double mins){
		return mins / 60 / 60;
	}
	
	public static void userChoice(){
		Scanner scanner = new Scanner(System.in);
		int choice = 0;
		double time = 0;
		
		System.out.println("Time Converter");
		System.out.println("******************");
		System.out.println("1.Hours To Minutes");
		System.out.println("2.Hours To Seconds");
		System.out.println("3.Minutes To Hours");
		System.out.println("4.Seconds To Hours");
		System.out.println("5.Exit");
		
		choice=scanner.nextInt();
		
		switch(choice){
			case 1:System.out.println("\nEnter in Hours...");
					time = scanner.nextDouble();
					System.out.println(time+ " Hrs = "+TimeConv.HrsToMins(time)+" Mins" );break;
			case 2:System.out.println("\nEnter in Hours");
					time = scanner.nextDouble();
					System.out.println(time+ " Hrs = "+TimeConv.HrsToSecs(time)+" Secs");break;
			case 3:System.out.println("\nEnter in Minutes");
					time = scanner.nextDouble();
					System.out.println(time+ " Mins = "+TimeConv.MinsToHrs(time)+" Hrs");break;
			case 4:System.out.println("\nEnter in Seconds");
					time = scanner.nextDouble();
					System.out.println(time+ " KM = "+TimeConv.SecsToHrs(time)+" Hrs");break;
			case 5:break;
			default:
					System.out.println("\nInvalid Choice..");break;
		}
	}
}

 

DistanceConv.java
package converters;

import java.util.Scanner;

public class DistanceConv{
	public static double MeterToKilometer(double Meter){
		return Meter /1000;
	}
	
	public static double MilesToKilometer(double Miles){
		return Miles * 1.60934;
	}
	
	public static double KilometerToMeter(double Km){
		return Km * 1000;
	}
	
	public static double KilometerToMiles(double Km){
		return Km /1.60934;
	}
	
	
	public static void userChoice(){
		Scanner scanner = new Scanner(System.in);
		int choice = 0;
		double distance = 0;
		
		System.out.println("Distance Converter");
		System.out.println("******************");
		System.out.println("1.Meter to Kilometer");
		System.out.println("2.Miles to Kilometer");
		System.out.println("3.Kilometer to Meter");
		System.out.println("4.Kilometer to Miles");
		System.out.println("5.Exit");
		
		choice=scanner.nextInt();
		
		switch(choice){
			case 1:System.out.println("\nEnter in Meters...");
					distance = scanner.nextDouble();
					System.out.println(distance+ " M = "+DistanceConv.MeterToKilometer(distance)+" KM" );break;
			case 2:System.out.println("\nEnter in Miles");
					distance = scanner.nextDouble();
					System.out.println(distance+ " Miles = "+DistanceConv.MilesToKilometer(distance)+" KM");break;
			case 3:System.out.println("\nEnter in Kilometer");
					distance = scanner.nextDouble();
					System.out.println(distance+ " KM = "+DistanceConv.KilometerToMeter(distance)+" M");break;
			case 4:System.out.println("\nEnter in KM");
					distance = scanner.nextDouble();
					System.out.println(distance+ " KM = "+DistanceConv.KilometerToMiles(distance)+" Miles");break;
			case 5:break;
			default:
					System.out.println("\nInvalid Choice..");break;
		}
	}
}

 

CurrencyConv.java
package converters;

import java.util.Scanner;

public class CurrencyConv{
	public static double EuroToInr(double Euro){
		return Euro * 80;
	}
	
	public static double DollarToInr(double Dollar){
		return Dollar * 66.89;
	}
	
	public static double YenToInr(double Yen){
		return Yen * 0.61;
	}
	
	public static double InrToEuro(double Inr){
		return Inr * 0.013;
	}
	
	public static double InrToDollar(double Inr){
		return Inr * 0.015;
	}
	
	public static double InrToYen(double Inr){
		return Inr * 1.63;
	}
	
	public static void userChoice(){
		Scanner scanner = new Scanner(System.in);
		int choice = 0;
		double money = 0;
		
		System.out.println("\nCurrency Converter");
		System.out.println("******************");
		System.out.println("1.EURO   to INR");
		System.out.println("2.DOLLAR to INR");
		System.out.println("3.YEN    to INR");
		System.out.println("4.INR to EURO");
		System.out.println("5.INR to DOLLAR");
		System.out.println("6.INR to YEN");
		System.out.println("7.Exit\n");
		
		choice=scanner.nextInt();
		
		switch(choice){
			case 1:System.out.println("\nEnter in EURO...");
					money = scanner.nextDouble();
					System.out.println(money+ " EURO = "+CurrencyConv.EuroToInr(money)+" INR" );break;
			case 2:System.out.println("\nEnter in DOLLAR");
					money = scanner.nextDouble();
					System.out.println(money+ " DOLLAR = "+CurrencyConv.DollarToInr(money)+" INR");break;
			case 3:System.out.println("\nEnter in YEN");
					money = scanner.nextDouble();
					System.out.println(money+ " YEN = "+CurrencyConv.YenToInr(money)+" INR");break;
			case 4:System.out.println("\nEnter in INR");
					money = scanner.nextDouble();
					System.out.println(money+ " INR = "+CurrencyConv.InrToEuro(money)+" EURO");break;
			case 5:System.out.println("\nEnter in INR");
					money = scanner.nextDouble();
					System.out.println(money+ " INR = "+CurrencyConv.InrToDollar(money)+" DOLLAR");break;
			case 6:System.out.println("\nEnter in INR");
					money = scanner.nextDouble();
					System.out.println(money+ " INR = "+CurrencyConv.InrToYen(money)+" YEN");break;
			case 7:break;
			default:
					System.out.println("Invalid Choice..");break;
		}
	}
}

Program Execution: