Created
October 11, 2012 00:25
-
-
Save wowmindy/3869395 to your computer and use it in GitHub Desktop.
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
import java.util.Scanner; | |
/*Mindy Mach | |
* Recitation 6 | |
* 10/2/12 | |
* CS160 | |
* mach@cs.colostate.edu | |
*/ | |
public class R6 { | |
public static void main (String[] args) { | |
Scanner keyboard = new Scanner(System.in); | |
//Phase 1 | |
String x; | |
do { | |
int upper = 0, lower = 0, digits = 0, specialchar = 0; | |
System.out.print("Enter a string: "); | |
x = keyboard.next(); | |
//Phase 2 | |
for(int y = 0; y < x.length(); y++){ | |
if (Character.isUpperCase(x.charAt(y))) | |
upper++; | |
else | |
if (Character.isLowerCase(x.charAt(y))) | |
lower++; | |
else | |
if (Character.isDigit(x.charAt(y))) | |
digits++; | |
else | |
specialchar++; | |
//System.out.println(x.charAt(y)); | |
} | |
System.out.println("Upper case letters: " + upper); | |
System.out.println("Lower case letters: " + lower); | |
System.out.println("Digits: " + digits); | |
System.out.println("Special characters: " + specialchar); | |
if (!x.equals("Exit")) | |
System.out.println(); | |
} | |
while(!x.equals("Exit")); | |
System.out.println("Goodbye!"); | |
//Phase 3 | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment