The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 2 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
anyone know how to fix this? someone on my class discussion board said "you forgot to insert a parameter String str in" just not sure how to do that thanks
Â
import java.util.Scanner;
/**
 * CS 170 Proficiency Quiz 4.
 * InsideOut2 program.
 *
 * @author Amir K
 * @version Summer 17
 */
public class InsideOut2
{Â Â
  /**
   * Write the insideOut2() function.
   *
   * @param str an even-length String of at least 2 characters.
   * @return a String as described below.
   *
   * The function has one parameter: a String strÂ
   * that is at least 2 characters long and of evenÂ
   * length. The function returns a new String whereÂ
   * the middle two characters have been removedÂ
   * and placed at the end.Â
   *Â
   * Here some sample input and output:
   *  insideOut2 ("Carton") returns "Caonrt" // rt moved to end
   *  insideOut2 ("Hi") returns "Hi" // Hi removed and then moved to end, so no change.Â
   *  insideOut2 ("Barbara Anne") returns "Barba Annera" //ra moves end.
   */
  // TODO WRITE THE FUNCTION insideOut2 HERE
  public static void main(String[] args)
  {
    System.out.println(insideOut2());
  }
  public static String insideOut2()
  {
    Scanner in = new Scanner(System.in);
    String str = in.nextLine();
    int wordLen = str.length();
    int centerLen = wordLen / 2;
    //Output
    String answer = (str.substring(0, centerLen - 1))
      + (str.substring(centerLen + 1, wordLen))
      + (str.substring(centerLen - 1, centerLen + 1));
    Â
    return answer;
  }
Â
}
Attachments:
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly