Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- countingCrow();
- }
- public static void countingCrow() {
- Scanner scan = new Scanner(System.in);
- String input;
- int screams = 0;
- int counter = 0;
- do {
- do {
- System.out.print("Inserisci una sequenza, oppure scrivi \"caw caw\" per conoscere il risultato: ");
- input = scan.nextLine();
- if (input.length()>3 && !input.equals("caw caw")) {
- System.out.println("Il corvo ha solo 3 occhi");
- }
- } while (input.length()>3 && !input.equals("caw caw"));
- if (!input.equals("caw caw")) {
- for (int i=0; i<input.length(); i++) {
- if (input.charAt(i)=='*') {
- counter += i==0 ? 4 : i==1 ? 2 : 1;
- }
- }
- } else {
- if (counter>1000) {
- counter = 1000;
- System.out.println(counter);
- counter = 0;
- screams++;
- } else {
- System.out.println(counter);
- counter = 0;
- screams++;
- }
- }
- } while (screams<3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement