πŸ“… Day 7 – Building UnitXpress | #30Days30Projects

Rushikesh UngeRushikesh Unge
3 min read

πŸ“Œ Project Overview

UnitXpress is a command-line Java application designed to simplify unit conversion. Whether you're dealing with distances, weights, temperatures, currencies (mocked), or even speed and area β€” UnitXpress has you covered.

This mini-tool aims to strengthen your understanding of:

  • Java’s switch statements

  • Scanner class input handling

  • Basic CLI design

  • Modular expansion for future features


πŸ› οΈ Technologies Used

  • Java (Core Java)

  • Command-Line Interface (CLI)


πŸ’‘ Features

The app currently supports:

Conversion TypeUnits
DistanceKilometers ↔ Miles
WeightKilograms ↔ Pounds
TemperatureCelsius ↔ Fahrenheit
CurrencyINR ↔ USD (Mock rate)
AreaSquare Meter ↔ Square Feet
Speedkm/h ↔ mph

πŸ”„ How It Works

Upon running the program, the user is presented with a menu of conversion options. After selecting a choice, the program prompts for an input value, performs the conversion, and displays the result.


🧠 Key Concepts Learned

  • Using switch-case for menu-based interaction

  • Real-world use of basic math functions

  • Creating a clean and interactive CLI application

  • Building expandable code structure for future enhancements


πŸ“„ Code Walkthrough

import java.util.Scanner;

public class UnitXpress {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int choice;

        do {
            System.out.println("\n========== UnitXpress CLI ==========");
            System.out.println("1. Kilometers ↔ Miles");
            System.out.println("2. Kilograms ↔ Pounds");
            System.out.println("3. Celsius ↔ Fahrenheit");
            System.out.println("4. INR ↔ USD (Mock)");
            System.out.println("5. Square Meter ↔ Square Feet");
            System.out.println("6. Speed: km/h ↔ mph");
            System.out.println("0. Exit");
            System.out.print("Choose conversion type: ");
            choice = sc.nextInt();

            switch (choice) {
                case 1:
                    System.out.print("Enter km: ");
                    double km = sc.nextDouble();
                    System.out.println("Miles: " + km * 0.621371);
                    break;
                case 2:
                    System.out.print("Enter kg: ");
                    double kg = sc.nextDouble();
                    System.out.println("Pounds: " + kg * 2.20462);
                    break;
                case 3:
                    System.out.print("Enter Celsius: ");
                    double c = sc.nextDouble();
                    System.out.println("Fahrenheit: " + (c * 9 / 5 + 32));
                    break;
                case 4:
                    System.out.print("Enter INR: ");
                    double inr = sc.nextDouble();
                    System.out.println("USD (Mock Rate 1 USD = 83 INR): " + (inr / 83));
                    break;
                case 5:
                    System.out.print("Enter sqm: ");
                    double sqm = sc.nextDouble();
                    System.out.println("sqft: " + (sqm * 10.7639));
                    break;
                case 6:
                    System.out.print("Enter km/h: ");
                    double kmh = sc.nextDouble();
                    System.out.println("mph: " + (kmh * 0.621371));
                    break;
                case 0:
                    System.out.println("Thank you for using UnitXpress");
                    break;
                default:
                    System.out.println("Invalid choice! Try again.");
            }
        } while (choice != 0);

        sc.close();
    }
}

πŸ–₯️ Sample Output

========== UnitXpress CLI ==========
1. Kilometers ↔ Miles
2. Kilograms ↔ Pounds
3. Celsius ↔ Fahrenheit
4. INR ↔ USD (Mock)
5. Square Meter ↔ Square Feet
6. Speed: km/h ↔ mph
0. Exit
Choose conversion type: 1
Enter km: 5
Miles: 3.106855

========== UnitXpress CLI ==========
Choose conversion type: 3
Enter Celsius: 100
Fahrenheit: 212.0

πŸš€ Ideas to Extend

  1. πŸ” Add Bi-directional Conversions (e.g., ask if user wants to go km ➝ miles or miles ➝ km)

  2. πŸ’± Use Real-Time Currency API (e.g., ExchangeRate API or OpenExchangeRates)

  3. 🎨 Build GUI with Swing/JavaFX

  4. πŸ“± Convert into an Android App for mobile tools

  5. πŸ’Ύ Add conversion history tracking


🎯 Learning Outcomes

  • Reinforced switch statements and loops in Java

  • Built confidence in accepting user input and handling edge cases

  • Practiced writing modular code that's easy to expand

  • Started thinking in terms of real-world utility when coding


πŸ“š Final Thoughts

This project proved that even a simple utility app can be a great way to reinforce fundamentals while building something useful. It’s beginner-friendly, practical, and scalable.

Whether you're just learning Java or looking to brush up on CLI tools β€” give UnitXpress a try, or fork it and make it your own!


πŸ”— GitHub Repo: https://github.com/Rushi-Unge/30Days30Projects
πŸ’¬ Share your feedback, or suggest more conversions!

0
Subscribe to my newsletter

Read articles from Rushikesh Unge directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rushikesh Unge
Rushikesh Unge