Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add DesafioControleFluxo #55

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions desafios/controle-fluxo/DesafioControleFluxo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Getting Started

Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.

## Folder Structure

The workspace contains two folders by default, where:

- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies

Meanwhile, the compiled output files will be generated in the `bin` folder by default.

> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management

The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
32 changes: 32 additions & 0 deletions desafios/controle-fluxo/DesafioControleFluxo/src/Contador.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import java.util.Scanner;

public class Contador {
public static void main(String[] args) {
Scanner terminal = new Scanner(System.in);
System.out.println("Digite o primeiro parâmetro");
int parametroUm = terminal.nextInt();
System.out.println("Digite o segundo parâmetro");
int parametroDois = terminal.nextInt();

try {
//chamando o método contendo a lógica de contagem
contar(parametroUm, parametroDois);

}catch (ParametrosInvalidosException exception) {
System.err.println("*** O segundo parâmetro deve ser maior que o primeiro ***");
}

}
static void contar(int parametroUm, int parametroDois ) throws ParametrosInvalidosException {
if(parametroUm <= parametroDois){
int contagem = parametroDois - parametroUm;

for(int i = 0; i <= contagem ; i++){
System.out.print(" | "+i);
}
}else{
throw new ParametrosInvalidosException();
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class ParametrosInvalidosException extends Exception{

}