diff --git a/.gitignore b/.gitignore index 496ee2c..89e80a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,15 @@ -.DS_Store \ No newline at end of file +# Gradle +.gradle/ +build/ + +# IDEA +.idea/ +*.iml + +# Compiled classes +**/out/ +**/*.class + +# OS +.DS_Store +Thumbs.db diff --git a/LICENSE b/LICENSE index 5c824c2..1c77da5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 Vinit Shahdeo +Copyright (c) 2025 Debora0Martins Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 306d108..9ac21a8 100644 --- a/README.md +++ b/README.md @@ -1,52 +1,27 @@ -

Hacktoberfest 2021

+# hacktoberfast2025Java — Calculadora Interativa -*** -

- - Link To HacktoberFest 2021 - -

+Este repositório contém uma pequena calculadora interativa em Java. -## Event details : +Estrutura recomendada (já aplicada): +- src/main/java/InteractiveCalculator.java -- Hacktoberfest® is open to everyone in our global community. Whether you’re a developer, student learning to code, event host, or company of any size, you can help drive growth of open source and make positive contributions to an ever-growing community. All backgrounds and skill levels are encouraged to complete the challenge. +Como compilar e executar -- Hacktoberfest is a celebration open to everyone in our global community. -- Pull requests can be made in any GitHub-hosted repositories/projects. -- You can sign up anytime between October 1 and October 31. +Opção A — sem Gradle (javac + java) +1. Compile: + javac -d out src/main/java/InteractiveCalculator.java +2. Execute: + java -cp out InteractiveCalculator -## HacktoberFest Rules : +Opção B — com Gradle (se tiver o Gradle instalado) +1. No diretório do projeto: + gradle run -To earn your Hacktoberfest tee or tree reward, you must register and make four valid pull requests (PRs) between October 1-31 (in any time zone). Pull requests can be made in any participating GitHub or GitLab hosted repository/project. Look for the 'hacktoberfest' topic to know if a repository/project is participating in Hacktoberfest. Pull requests must be approved by a maintainer of the repository/project to count. If a maintainer reports your pull request as spam or behavior not in line with the project’s code of conduct, you will be ineligible to participate. This year, the first 55,000 participants who successfully complete the challenge will be eligible to receive a prize. -*** -

Whether it’s your first or fiftieth pull request, there’s always more to learn! We’ve put together a few resources that can help you create quality pull requests, keep your repositories pristine, and build on your open source knowledge.

+Observações +- O projeto usa package padrão (sem package) para manter simples. +- Se quiser executar sem ter o Gradle instalado, eu posso adicionar o Gradle Wrapper (arquivos `gradlew`), assim qualquer usuário pode rodar `./gradlew run` (Unix) ou `gradlew.bat run` (Windows). -*** - -

- - Join Discord Conversation - -

- -*** -## Rules To Contribute To This Repo - -- Use any language. -- C, C++, JAVA, Data Structure and Algorithms, HTML, CSS, Android Projects. -- Anything valuable. -![Alt Text](https://res.cloudinary.com/practicaldev/image/fetch/s--Gg3AHVhQ--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/of9b6i02ifmdq5zlbmkz.jpg) - -## Steps For Contribution - - 1. Fork this repo - 2. Star this repo - 3. Add a file - 4. commit the code - 5. Make pull request -*** -

-

- Thank You -

-

+Melhorias possíveis +- Adicionar testes unitários com JUnit. +- Empacotar como JAR executável. +- Adicionar Gradle Wrapper para rodar sem instalar Gradle. diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..df1ff49 --- /dev/null +++ b/build.gradle @@ -0,0 +1,15 @@ +plugins { + id 'application' +} + +group = 'com.github.debora0martins' +version = '1.0.0' + +repositories { + mavenCentral() +} + +application { + // For Gradle 7+: replace with mainClass.set('InteractiveCalculator') if needed + mainClass = 'InteractiveCalculator' +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..c875536 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'hacktoberfast2025Java' \ No newline at end of file diff --git a/src/main/java/InteractiveCalculator.java b/src/main/java/InteractiveCalculator.java new file mode 100644 index 0000000..eb48ce2 --- /dev/null +++ b/src/main/java/InteractiveCalculator.java @@ -0,0 +1,46 @@ +import java.util.InputMismatchException; +import java.util.Scanner; + +public class InteractiveCalculator { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + System.out.println("=== Calculadora Interativa ==="); + + try { + System.out.print("Digite o primeiro número: "); + double a = scanner.nextDouble(); + + System.out.print("Digite o segundo número: "); + double b = scanner.nextDouble(); + + System.out.print("Escolha a operação (+, -, *, /): "); + char op = scanner.next().charAt(0); + + double result; + switch (op) { + case '+': result = a + b; break; + case '-': result = a - b; break; + case '*': result = a * b; break; + case '/': + if (b == 0) { + System.out.println("Erro: divisão por zero."); + scanner.close(); + return; + } else { + result = a / b; + } + break; + default: + System.out.println("Operação inválida."); + scanner.close(); + return; + } + + System.out.println("Resultado: " + result); + } catch (InputMismatchException e) { + System.out.println("Entrada inválida. Use números (ex.: 1.23)."); + } finally { + scanner.close(); + } + } +} \ No newline at end of file