I've been studying java as a hobby for some time and was doing some basic exercises, but a silly little code of mine is really stubborn and doesn't want to work.


import java.time.LocalDate;
import java.util.Scanner;

public class App {
    public static void main(String[] args) throws Exception {
    
        try (Scanner aging = new Scanner(System.in)) {
            String text = "Olá! Por favor, para começarmos o seu cadastro na empresa 'totalmentenãovamosvenderseusdadosdepois LTD.' digite o seu ano de nascimento para checarmos se você está apto para ser escr- trabalhar conosco!";
            int i;
            for (i = 0; i < text.length(); i++) {
                System.out.printf("%C", text.charAt(i));
                try {
                    Thread.sleep(25);
                } catch (InterruptedException ex) {
                    Thread.currentThread().interrupt();
                }
            }
            System.out.println("        ");
            int year = aging.nextInt();

            String text2 = "Okay! Vamos calcular sua aptidão!";
            int o;
            for (o = 0; o < text2.length(); o++) {
                System.out.printf("%C", text2.charAt(o));
                {
                    try {
                        Thread.sleep(25);
                    } catch (InterruptedException ex) {
                        Thread.currentThread().interrupt();
                    }
                }

                int idade = (LocalDate.now().getYear() - year);

                if (idade <= 50) {
                    String text3 = ("Parece que você é inocen- a-apto o suficiente para trabalhar aqui");
                    int a;
                    for (a = 0; a < text3.length(); a++) {
                        System.out.printf("%C", text3.charAt(a));
                        try {
                            Thread.sleep(25);
                        } catch (InterruptedException ex) {
                            Thread.currentThread().interrupt();
                        }
                    }
                }
                else (idade>50) {
                    String text4 = ("Parece que você é vel- experiente demais e acreditamos que seria melhor apreciado em outra empresa!");
                    int c;
                    for (c = 0; c < text4.length(); c++) {
                        System.out.printf("%C", text4.charAt(c));
                        try {
                            Thread.sleep(25);
                        } catch (InterruptedException ex) {
                            Thread.currentThread().interrupt();
                        }
                    }
                }
            }
        }
    }
}

It then gives me 3 errors

The left-hand side of an assignment must be a variable (Ln 48, Col 22)

Syntax error, insert "AssignmentOperator Expression" to complete Assignment (Ln 48, Col 31)

If I use If instead of else, it runs okay, but then it keeps on a loop.

0

There are 0 best solutions below