Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Day11A {
- public static void main(String[] args) {
- // Day11A callMe = new Day11A();
- char chABC = 't';
- String txtRef = "The quick brown fox jumps over the lazy dog";
- printLetterCount(chABC, txtRef);
- for (char ch1 = 'a'; ch1 <= 'z';ch1++){
- System.out.println(ch1);
- }
- }
- static void printLetterCount(char chFind, String txtSample) {
- int letterCount = 0;
- int nextIndex = 0;
- int charCount = 0;
- for (int i = 0; i < txtSample.length(); i++) {
- nextIndex = txtSample.toLowerCase().indexOf(chFind,i);
- i = nextIndex;
- if (i == -1) {
- break;
- }
- charCount++;
- }
- System.out.println(chFind + " : " + charCount);
- }
- }
- //---------------------------------
- public class Day11B {
- public static void main(String[] args) {
- String practiceText = "Username;Identifier;First name;Last name";
- String[] resultArray = practiceText.split(";");
- for (String string : resultArray) {
- System.out.print(string + " | ");
- }
- System.out.println();
- String[] csvSample = { "booker12;9012;Rachel;Booker"
- ,"grey07;2070;Laura;Grey"
- ,"johnson81;4081;Craig;Johnson"
- ,"jenkins46;9346;Mary;Jenkins"
- ,"smith79;5079;Jamie;Smith"};
- for (String csvString : csvSample) {
- String[] csvToArray = csvString.split(";");
- for (String string : csvToArray) {
- System.out.print(string + " | ");
- }
- System.out.println();
- }
- }
- }
- //---------------------------------
- public class Day11D {
- public static void main(String[] args) {
- String name = "Terry";
- String hobby = "Plastic Model Making";
- byte age = 12;
- String resultMessage;
- resultMessage = String.format("Good day I’m %s age %d", name, age);
- System.out.println(resultMessage);
- resultMessage = String.format("My hobbies are %s", hobby);
- System.out.println(resultMessage);
- String txtCSV = "Username;Identifier;First name;Last name";
- String[] csvArray = txtCSV.split(";");
- System.out.printf("%-12s | %-10s | %-12s | %-12s |%n"
- ,csvArray[0],csvArray[1],csvArray[2],csvArray[3]);
- txtCSV = "jenkins46;9346;Mary;Jenkins";
- csvArray = txtCSV.split(";");
- System.out.printf("%-12s | %-10s | %-12s | %-12s |%n"
- ,csvArray[0],csvArray[1],csvArray[2],csvArray[3]);
- String[] csvSample = { "booker12;9012;Rachel;Booker"
- ,"grey07;2070;Laura;Grey"
- ,"johnson81;4081;Craig;Johnson"
- ,"smith79;5079;Jamie;Smith"};
- }
- }
- //---------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement