Anzeige
Write a method checkCharacter0 which has 2 parameters A Str.pdf
Nächste SlideShare
Write a method that checks whether an arithmetic expression is valid-.docxWrite a method that checks whether an arithmetic expression is valid-.docx
Wird geladen in ... 3
1 von 1
Anzeige

Más contenido relacionado

Más de vivekemailid(20)

Anzeige

Write a method checkCharacter0 which has 2 parameters A Str.pdf

  1. Write a method checkCharacter0 which has 2 parameters: A String, and a specified index (an int). Method checkcharacter0 checks the character at the specified index of the String parameter, and returns a String based on the type of character at that location indicating if the character is a letter, digit, whitespace, or unknown character: Ex: The method calis below with the given arguments will return the following Strings: checkCharacter " "happy birthday", 2) returns "Character "p' is a letter" checkCharacter ("happy birthday", 5) returns "Character" is a white space" checkCharacter ("happy birthday 2 you", 15) returns "Character '2' is a digit' checkCharacter ("happy birthday!", 14) returns "Character'" is unknown: Your program must define the method public String checkCharacter(string word, int index)import java.util. Scanner; public class FunWithCharacters { /* Type your code here */ public static void main(String [] args) { FunWithCharacters lab0bject = new FunWithCharters(); String word = "happy birthday"; // Set string int index =2;1/ Set specified index to 2 System. out.println(labobject. checkCharacter(word, index)); index =5;/1 Set specified index to 5 System. out.println(labObject. checkCharacter(word, index)); word = "happy birthday 2 you"; index =15; // Set specified index to 15 System. out.println(labObject. checkCharacter(word, index)); word = "happy birthday!"; index =14;// Set specified index to 14 System. out.println(labObject. checkCharacter(word, index));
Anzeige