write a java program to input a sentence and print second last alphabet of each word(using buffered reader only)any scam or other answers will be reported
Answers
Answer:
/ Java implementation of the approach
class GFG {
// Function to print the last character
// of each word in the given string
static void printLastChar(String str)
{
// Now, last word is also followed by a space
str = str + " ";
for (int i = 1; i < str.length(); i++) {
// If current character is a space
if (str.charAt(i) == ' ')
// Then previous character must be
// the last character of some word
System.out.print(str.charAt(i - 1) + " ");
}
}
// Driver code
public static void main(String s[])
{
String str = "Geeks for Geeks";
printLastChar(str);
}
}
Answer:
import java.io.*;
public class abc
{
public static void main (String args[ ])throws IOException
{
BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
String s,st; int p;
s=br.read( );
st=s+"";
p=st.length( );
int i; String wd = ""; char ch;
for (i=0;i<=p;i++)
{
ch=st.charAt (i);
if (ch==' ')
wd = wd+(ch-2);
}
System.out.println ("The desired answer="+wd);
}
}
Hope it helps you successfully...
Please mark me as the brainliest...