Project Idea: Unit Converter App (Command-Line Based) for practising Swift
Create a console-based unit converter app where users can convert between different units (e.g., kilometers to miles, Celsius to Fahrenheit, etc.). This project focuses on functions and reinforces your understanding of inputs, outputs, and decision-making.
Menu for Unit Conversion: Present a menu to the user (e.g., "1. Convert kilometers to miles, 2. Convert Celsius to Fahrenheit"). Functions for Conversions: Write separate functions for each conversion type (e.g., convertKmToMiles(km: Double) -> Double). User Input: Prompt the user for input values (e.g., kilometers or Celsius) and call the appropriate function. Repeat Option: After a conversion, ask the user if they want to perform another conversion or exit the app.
Welcome to the Unit Converter! Please choose an option:
- Convert kilometers to miles
- Convert Celsius to Fahrenheit
- Exit
Enter your choice: 1 Enter the distance in kilometers: 5 5 kilometers is equal to 3.11 miles.
Do you want to convert another unit? (yes/no): yes
- Function creation and usage.
- Handling user input and output.
- Conditional statements (if, switch).
- Loops (for repetitive tasks).