forked from Aniket965/Hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Aniket965#915 from luanaplins/master
Added a program that counts UpCaseLetters
- Loading branch information
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import java.util.*; | ||
import java.io.*; | ||
|
||
public class Atividade1 | ||
{ | ||
static int ContarMaiusculas (String x) | ||
{ | ||
int cont=0; | ||
for(int y=0;y<x.length();y++) | ||
{ | ||
if(x.charAt(y)>='A' && x.charAt(y)<='Z') | ||
cont++; | ||
} | ||
return cont; | ||
} | ||
|
||
static boolean Palindromo (String x) | ||
{ | ||
boolean teste=true; | ||
int cont1=0; | ||
int tam=x.length(); | ||
System.out.println(tam); | ||
for(int y=0;y<x.length();y++) | ||
{ | ||
if(x.charAt(y)==x.charAt(tam-cont1-1)) | ||
{ | ||
cont1++; | ||
|
||
} | ||
else | ||
return false; | ||
} | ||
return teste; | ||
} | ||
|
||
static String Ciframento (String x) | ||
{ | ||
String d; | ||
int ct; | ||
char c; | ||
int tam=x.length(); | ||
char[] xc= x.toCharArray(); | ||
for(int y=0;y<tam;y++) | ||
{ | ||
c=xc[y]; | ||
ct=Character.getNumericValue(c); | ||
ct+=3; | ||
c=(char)(ct + '0' + 7 + 32); | ||
xc[y] = c; | ||
} | ||
d= String.valueOf(xc); | ||
|
||
return d; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
public static void main (String[]args) | ||
{ | ||
Scanner ler=new Scanner(System.in); | ||
String z; | ||
System.out.println("Digite Uma Frase:"); | ||
z=ler.nextLine(); | ||
System.out.println(ContarMaiusculas(z)); | ||
System.out.println(Palindromo(z)); | ||
System.out.println(Ciframento(z)); | ||
} | ||
} |