commit inicial exercicio dificil
commit
b6e2d3a4ec
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.mycompany</groupId>
|
||||||
|
<artifactId>mavenprojectString2</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.release>24</maven.compiler.release>
|
||||||
|
<exec.mainClass>com.mycompany.mavenprojectstring2.MavenprojectString2</exec.mainClass>
|
||||||
|
</properties>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
*/
|
||||||
|
package com.mycompany.mavenprojectstring2;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author 250420
|
||||||
|
*/
|
||||||
|
public class MavenprojectString2 {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
System.out.println("Introduza o seu nome");
|
||||||
|
String nome = scanner.nextLine();
|
||||||
|
|
||||||
|
System.out.println("A Quantidade de caracteres é " + nome.length());
|
||||||
|
System.out.println("Em maiusculas:" + nome.toUpperCase());
|
||||||
|
System.out.println("Em minusculas: " + nome.toLowerCase());
|
||||||
|
System.out.println("Contem campos? " + nome.contains("campos"));
|
||||||
|
System.out.println("O primeiro caracter é: " + nome.charAt(0));
|
||||||
|
System.out.println("Qual o caracter do meio: " + nome.charAt(nome.length() / 2));
|
||||||
|
int contador = 0;
|
||||||
|
for (int i = 0; i < nome.length(); i++) {
|
||||||
|
if (nome.charAt(i) == 'a') {
|
||||||
|
contador++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("O nome tem" + contador);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue