Skip to content

Instantly share code, notes, and snippets.

@henvic
Last active December 27, 2015 02:09
Show Gist options
  • Save henvic/7250635 to your computer and use it in GitHub Desktop.
Save henvic/7250635 to your computer and use it in GitHub Desktop.
package teste;
import java.util.Scanner;
public class Montanhas {
public static void main(String[] args) {
String pos;
boolean end = false;
int peaks;
int mountains;
Scanner input = new Scanner(System.in);
while (!end) {
System.out.print("Posição das montanhas (Vertical/Horizontal):");
pos = input.nextLine();
System.out.print("Quantidade de montanhas:");
peaks = input.nextInt();
input.nextLine();
if (pos.equals("Vertical")) {
for (mountains = 0; mountains <= peaks - 1; mountains = mountains + 1) {
System.out.println(" x \n xxx \nxxxxx");
}
}
if (pos.equals("Horizontal")) {
for (mountains = 0; mountains <= peaks; mountains = mountains + 1) {
System.out.println("x \nxx \nx");
}
}
System.out.println("Você quer continuar?");
end = !input.nextLine().equals("sim");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment