0% found this document useful (0 votes)
42 views1 page

Carateclado

The document is a Java program that reads characters from user input, counts the number of 'a' characters, and counts the number of 'A' characters. It prompts the user to enter a string, uses a for loop to iterate through each character, and increments the counters for 'a' and 'A'. It then prints out the number of each character.

Uploaded by

api-16774418
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views1 page

Carateclado

The document is a Java program that reads characters from user input, counts the number of 'a' characters, and counts the number of 'A' characters. It prompts the user to enter a string, uses a for loop to iterate through each character, and increments the counters for 'a' and 'A'. It then prints out the number of each character.

Uploaded by

api-16774418
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

//Leyendo caracteres a y A desde el teclado

import java.io.*;
public class NumeroA {
public static void main (String [] args) {
BufferedReader in = new BufferedReader ( new
InputStreamReader( System.in ) );
String c="";
int a=0,A=0;
System.out.print("Introduce una cadena de caracteres:
");
try {
c = in.readLine();
}
catch (Exception exc )
{ System.out.println( exc ); }
for (int i=0; i<c.length(); i++) {
if ((c.charAt(i)=='a')) {
a++;
}
if
((c.charAt(i)=='A')) {
A++;
}
}
System.out.print("El numero de caracteres a es");
System.out.println(": " +a);
System.out.print("El numero de caracteres A es");
System.out.println(": " +A);
}
}

You might also like