Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 16) Escreva um programa que informe se todos os caracteres alfabéticos de uma frase
- fornecida pelo usuário são maiúsculos.
- */
- import java.util.Scanner;
- public class Ex16 {
- public static void main(String args[]){
- Scanner leia = new Scanner(System.in);
- System.out.print("Entre com a frase: ");
- String frase = leia.nextLine();
- int tamanho = frase.length();
- int mai = 0, min = 0;
- for(int i=0; i<tamanho; i++){
- if((frase.substring(i,i+1).equals("A")) || (frase.substring(i,i+1).equals("B")) || (frase.substring(i,i+1).equals("C")) ||
- (frase.substring(i,i+1).equals("D")) || (frase.substring(i,i+1).equals("E")) || (frase.substring(i,i+1).equals("F")) ||
- (frase.substring(i,i+1).equals("G")) || (frase.substring(i,i+1).equals("H")) || (frase.substring(i,i+1).equals("I")) ||
- (frase.substring(i,i+1).equals("J")) || (frase.substring(i,i+1).equals("K")) || (frase.substring(i,i+1).equals("L")) ||
- (frase.substring(i,i+1).equals("M")) || (frase.substring(i,i+1).equals("N")) || (frase.substring(i,i+1).equals("O")) ||
- (frase.substring(i,i+1).equals("P")) || (frase.substring(i,i+1).equals("Q")) || (frase.substring(i,i+1).equals("R")) ||
- (frase.substring(i,i+1).equals("S")) || (frase.substring(i,i+1).equals("T")) || (frase.substring(i,i+1).equals("U")) ||
- (frase.substring(i,i+1).equals("V")) || (frase.substring(i,i+1).equals("X")) || (frase.substring(i,i+1).equals("Z")) ||
- (frase.substring(i,i+1).equals("Y")) || (frase.substring(i,i+1).equals("W"))) {
- mai++;
- } else if((frase.substring(i,i+1).equals("a")) || (frase.substring(i,i+1).equals("b")) || (frase.substring(i,i+1).equals("c")) ||
- (frase.substring(i,i+1).equals("d")) || (frase.substring(i,i+1).equals("e")) || (frase.substring(i,i+1).equals("f")) ||
- (frase.substring(i,i+1).equals("g")) || (frase.substring(i,i+1).equals("h")) || (frase.substring(i,i+1).equals("i")) ||
- (frase.substring(i,i+1).equals("j")) || (frase.substring(i,i+1).equals("k")) || (frase.substring(i,i+1).equals("l")) ||
- (frase.substring(i,i+1).equals("m")) || (frase.substring(i,i+1).equals("n")) || (frase.substring(i,i+1).equals("o")) ||
- (frase.substring(i,i+1).equals("p")) || (frase.substring(i,i+1).equals("q")) || (frase.substring(i,i+1).equals("r")) ||
- (frase.substring(i,i+1).equals("s")) || (frase.substring(i,i+1).equals("t")) || (frase.substring(i,i+1).equals("u")) ||
- (frase.substring(i,i+1).equals("v")) || (frase.substring(i,i+1).equals("x")) || (frase.substring(i,i+1).equals("z")) ||
- (frase.substring(i,i+1).equals("y")) || (frase.substring(i,i+1).equals("w"))) {
- min++;
- }
- }
- if(min>0){
- System.out.print("\nNem todos os caracteres alfabeticos são maiúsculos.");
- } else {
- System.out.print("\nTodos os caracteres alfabeticos são maiúsculos.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement