diff --git a/README.md b/README.md index a07416a..b7ec617 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,22 @@ # codex-test -This is my first manual commit in GitHub. -This is my second manual update in GitHub. -This is my third manual change in GitHub. -This is my fourth manual change in GitHub. - -# codex-test - -This repository contains simple **command-line To-Do List applications** written in both Python and Java. -They demonstrate how to build interactive console apps, store data locally, and perform common CRUD operations (Create, Read, Update, Delete). - ---- +This repository contains simple command-line applications written in Python and Java. ## Files -- **todo.py** – Python version (stores tasks in `tasks.json`) -- **Todo.java** – Java version (stores tasks in `tasks.csv`) +- **todo.py** – Python to-do list (stores tasks in `tasks.json`) +- **Todo.java** – Java to-do list (stores tasks in `tasks.csv`) - **practice.py** – Additional practice/testing file - ---- +- **TemperatureConverter.java** – Java temperature conversion utility ## How to Run – Python Version -**Requirements:** Python 3.7+ +**Requirements:** Python 3.7+ ```bash python3 todo.py +``` + +## How to Run – Temperature Converter +**Requirements:** Java 11+ +```bash +javac TemperatureConverter.java +java TemperatureConverter +``` diff --git a/TemperatureConverter.java b/TemperatureConverter.java index 3ce326b..d3f48ac 100644 --- a/TemperatureConverter.java +++ b/TemperatureConverter.java @@ -2,6 +2,30 @@ public class TemperatureConverter { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + System.out.println("Temperature Converter"); + System.out.print("Enter temperature value: "); + if (!scanner.hasNextDouble()) { + System.out.println("Invalid temperature."); + scanner.close(); + return; + } + double value = scanner.nextDouble(); + System.out.print("Convert to (C/F): "); + String unit = scanner.next().trim().toUpperCase(); + if (unit.equals("C")) { + double celsius = (value - 32) * 5.0 / 9.0; + System.out.printf("%.2f F = %.2f C%n", value, celsius); + } else if (unit.equals("F")) { + double fahrenheit = value * 9.0 / 5.0 + 32; + System.out.printf("%.2f C = %.2f F%n", value, fahrenheit); + } else { + System.out.println("Unknown unit. Please use 'C' or 'F'."); + } + scanner.close(); +======= + private static double cToF(double c) { return c * 9.0 / 5.0 + 32.0; }