Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

On a sheet of paper, write a Java program that will: Ask the user to enter a wor

ID: 3670663 • Letter: O

Question

On a sheet of paper, write a Java program that will: Ask the user to enter a word, and read it into a String variable Count the number of lower-case letters in the word, and print the result You can tell if a letter is lower-case like this:

char letter;

//suppose letter has been initialized if (Character.isLowerCase(letter)) {

//you know that letter is lower-case now

//write the code to process letter

}

You will want an if-statement like the above inside a loop that steps through each character in the word.

Explanation / Answer

import java.util.*;

public class Example {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print("Enter word: ");
String word = sc.nextLine();

int total=0;
for(int i=0;i<word.length();i++){
char letter = word.charAt(i);
if (Character.isLowerCase(letter)){
total = total + 1;
}
}
System.out.println("Total: " + total);

}
}

Source(s):http://javacodex.com

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote