Question
programming language:JAVA
show all thr work and follow the instruction
1. The method below was presented in the course documents: import java.io. public class Drivert public static void main(Stringll args) throws java.io. IOException f System.out.println ("Enter string: ") foo l; public static void foo() throws java.io.IOException ( char c = (char) System.in.read(); if (c != '.') foo ()i System.out.print (c) ; Its purpose is to reverse the characters in an input stream. For example, if the input to the method is: HELLO. then the output produced by the method is: .OLLEH See if you can modify the method so the period does not appear in the ou stream. Note that I do not want you to give as the solution: tput System.out.print(c)
Explanation / Answer
just change these lines if(c != '.') foo(); System.out.print(c); to if(c != '.') { foo(); System.out.print(c); } Explanation: ------------- All you had to do was only print c if it is not '.'. so, just take printing c part inside if block.