1 2 3 Previous Next 36 Replies Latest reply on Oct 10, 2008 11:10 AM by 843785

    Need help~~~ Midterm tomorrow!!!

    843785
      1. Implement a method named replace that will ask the user to enter their first name.
      The method will then print (to the screen) the name with the last letter replaced with a dollar sign.

      If the name is Jack the output will be  Jac$


      Thats the problem..

      So far I got...

      import java.util.Scanner;


      public class Jack {

      /**
      * @param args
      */
      public static void main(String[] args) {
      // TODO Auto-generated method stub


      String str = "Jack";
      str = str.replace('k', '$');
      System.out.println(str);



      It prints out Jac$

      But how do i make it say : Please enter your name:


      I tried adding System.out.println ("Please enter your first name: );
        1 2 3 Previous Next