Question

DO NOT USE ANY EXTERNAL LIBRARIES! KEEP IT SIMPLE!!!

import java.util.Scanner;
public class StoryTime {
  
/*Method name : descrambler()
@returns: String
@param: int
@param: String
*/
// Make your method here

   public static void main(String[] args) {
       StoryTime s = new StoryTime();
       Scanner scn = new Scanner(System.in);
       System.out.println("Pick 1 for a joke or 2 for a Short Scary Story");
       int input = scn.nextInt();
       String str = "Juswert alois Iuyr waqies fplminiqweshenmcd wkjhashasfingwtf thttye dpolishertes ionm"
               + "y bcvdauertghthjker bnmpulqweledghi onopl mywdf yebghlloderw dlosrescxzs apernd fdsbecuytkonlkjed ghjme asdto qwefoltyulo"
               + "wxcv hethmr tasro hjmner dfgroolkom. ewrShehyt stolkilldfg hewerld gfdtigjk8htlloiy adfgs Injk wacdflkelopd iplontocct "
               + "thmnbe ebnmmptcvby rbvcoomxzs, rweremetyumberewrinqasg tghjhatcvg myghj dauioughploteriuy hartyd dwqsiedytr twfgho whjkeekbfds ahjkgo."
               + "I erthrtretyw yua uiboioomoperasansdg dfa fgfeghw hjyejkarkls l;agzxo.xc Icv nvbownm lerivtye uiinjk cfgondfstweancvt asfedfarer. ";
       if(input ==1 || input == 2) {
       String Story = s.descrambler(input, str);
       System.out.println(Story);
       }
       else {
           System.out.println("Invalid Input");
       }
      
   }

}

13.5 Short Story Its October the spooky time of the year. This lab will use for loops, substring, and string concatenation t

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code for above Question:- (after code i have attached the image of running code with output )

import java.util.*;
public class StoryTime {
   private String descrambler(int param,String str){
       String story=new String();
       for(int i=0;i<str.length();i +=6){
           if(param==2 && i<459){
               story=story+str.substring(i,i+3);
           }
           }
       for(int i=459;i<str.length();i +=4){
           if(param==1){
               story=story+str.substring(i,i+2);
           }
           }
       return story;
   }
   public static void main(String[] args){
       StoryTime st=new StoryTime();
       Scanner scn =new Scanner(System.in);
       System.out.println("Pick 1 for a joke or 2 for a Short Scary Story:");
   int input = scn.nextInt();
   String str = "Juswert alois Iuyr waqies fplminiqweshenmcd wkjhashasfingwtf thttye dpolishertes ionm"
   + "y bcvdauertghthjker bnmpulqweledghi onopl mywdf yebghlloderw dlosrescxzs apernd fdsbecuytkonlkjed ghjme asdto qwefoltyulo"
   + "wxcv hethmr tasro hjmner dfgroolkom. ewrShehyt stolkilldfg hewerld gfdtigjk8htlloiy adfgs Injk wacdflkelopd iplontocct "
   + "thmnbe ebnmmptcvby rbvcoomxzs, rweremetyumberewrinqasg tghjhatcvg myghj dauioughploteriuy hartyd dwqsiedytr twfgho whjkeekbfds ahjkgo."
   + "I erthrtretyw yua uiboioomoperasansdg dfa fgfeghw hjyejkarkls l;agzxo.xc Icv nvbownm lerivtye uiinjk cfgondfstweancvt asfedfarer. ";
   if(input ==1 || input == 2) {
   String Story = st.descrambler(input, str);
   System.out.println(Story);
   }
   else {
   System.out.println("Invalid Input");
   }
       }
}
4 public class StoryTime { private String descrambler(int param, String str) 1 String story=new String(); for(int i=0;i<str.l

Add a comment
Know the answer?
Add Answer to:
DO NOT USE ANY EXTERNAL LIBRARIES! KEEP IT SIMPLE!!! import java.util.Scanner; public class StoryTime {   ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • import java.util.Scanner; public class TriangleMaker {    public static void main(String[] args) {        //...

    import java.util.Scanner; public class TriangleMaker {    public static void main(String[] args) {        // TODO Auto-generated method stub        System.out.println("Welcome to the Triangle Maker! Enter the size of the triangle.");        Scanner keyboard = new Scanner(System.in);    int size = keyboard.nextInt();    for (int i = 1; i <= size; i++)    {    for (int j = 0; j < i; j++)    {    System.out.print("*");    }    System.out.println();    }    for (int...

  • DO NOT USE ANY EXTERNAL LIBRARIES BESIDES BUILT IN JAVA LIBRARIES! KEEP IT SIMPLE!!! Provided Code:...

    DO NOT USE ANY EXTERNAL LIBRARIES BESIDES BUILT IN JAVA LIBRARIES! KEEP IT SIMPLE!!! Provided Code: import java.util.Scanner; public class OddAndEven{ /* PART 1: Create a nonstatic method that takes in an int number quantity (n) and returns a returns a String of numbers from 0 to n (inclusive) as the example above demonstrates. Call this quantityToString.    In this method you should check that n is between 0(inclusive) and 100(inclusive). If n is outside these boundaries return and empty...

  • Given java code is below, please use it! import java.util.Scanner; public class LA2a {      ...

    Given java code is below, please use it! import java.util.Scanner; public class LA2a {       /**    * Number of digits in a valid value sequence    */    public static final int SEQ_DIGITS = 10;       /**    * Error for an invalid sequence    * (not correct number of characters    * or not made only of digits)    */    public static final String ERR_SEQ = "Invalid sequence";       /**    * Error for...

  • import java.util.Scanner; import java.util.ArrayList; public class P3A2_BRANDT_4005916 {    public static void main(String[] args)    {...

    import java.util.Scanner; import java.util.ArrayList; public class P3A2_BRANDT_4005916 {    public static void main(String[] args)    {        String name;        String answer;        int correct = 0;        int incorrect = 0;        Scanner phantom = new Scanner(System.in);        System.out.println("Hello, What is your name?");        name = phantom.nextLine();        System.out.println("Welcome " + name + "!\n");        System.out.println("My name is Danielle Brandt. "            +"This is a quiz program that...

  • Explain this java code, please. import java.util.Scanner; public class Program11 { public static void main(String[] args)...

    Explain this java code, please. import java.util.Scanner; public class Program11 { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); final int maxSize = 128; String[] titles = new String[maxSize]; int[] lengths = new int[maxSize]; int numDVDs = 0; String op; op = menu(stdIn); System.out.println(); while (!op.equalsIgnoreCase("q")) { if (op.equalsIgnoreCase("a")) { if (numDVDs < maxSize) numDVDs = addDVD(titles, lengths, numDVDs, stdIn); } else if (op.equalsIgnoreCase("t")) searchByTitle(titles, lengths, numDVDs, stdIn);    else if (op.equalsIgnoreCase("l")) searchByLength(titles, lengths, numDVDs, stdIn); System.out.println('\n');...

  • This is the contents of Lab11.java import java.util.Scanner; import java.io.*; public class Lab11 { public static...

    This is the contents of Lab11.java import java.util.Scanner; import java.io.*; public class Lab11 { public static void main(String args[]) throws IOException { Scanner inFile = new Scanner(new File(args[0])); Scanner keyboard = new Scanner(System.in);    TwoDArray array = new TwoDArray(inFile); inFile.close(); int numRows = array.getNumRows(); int numCols = array.getNumCols(); int choice;    do { System.out.println(); System.out.println("\t1. Find the number of rows in the 2D array"); System.out.println("\t2. Find the number of columns in the 2D array"); System.out.println("\t3. Find the sum of elements...

  • Can you help me with this code in Java??? import java.util.Scanner; public class Main { public...

    Can you help me with this code in Java??? import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int rows = 3; int columns = 4; int[][] arr = new int[rows][columns]; for(int i = 0; i < rows; ++i) { for(int j = 0; j < columns; ++j) { System.out.println("Enter a value: "); arr[i][j] = scan.nextInt(); } } System.out.println("The entered matrix:"); for(int i = 0; i < rows; ++i) { for(int j...

  • Need help with the UML for this code? Thank you. import java.util.Scanner;    public class Assignment1Duong1895...

    Need help with the UML for this code? Thank you. import java.util.Scanner;    public class Assignment1Duong1895    {        public static void header()        {            System.out.println("\tWelcome to St. Joseph's College");        }        public static void main(String[] args) {            Scanner input = new Scanner(System.in);            int d;            header();            System.out.println("Enter number of items to process");            d = input.nextInt();      ...

  • Convert Code from Java to C++ Convert : import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class...

    Convert Code from Java to C++ Convert : import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Template { public static void main(String args[]) { Scanner sc1 = new Scanner(System.in); //Standard input data String[] line1 = sc1.nextLine().split(","); //getting input and spliting on basis of "," String[] line2 = sc1.nextLine().split(" "); //getting input and spiliting on basis of " "    Map<String, String> mapping = new HashMap<String, String>(); for(int i=0;i<line1.length;i++) { mapping.put(line1[i].split("=")[0], line1[i].split("=")[1]); //string in map where in [] as key and...

  • Project 7-3 Guessing Game import java.util.Scanner; public class GuessNumberApp {    public static void main(String[] args)...

    Project 7-3 Guessing Game import java.util.Scanner; public class GuessNumberApp {    public static void main(String[] args) { displayWelcomeMessage(); // create the Scanner object Scanner sc = new Scanner(System.in); String choice = "y"; while (choice.equalsIgnoreCase("y")) { // generate the random number and invite user to guess it int number = getRandomNumber(); displayPleaseGuessMessage(); // continue until the user guesses the number int guessNumber = 0; int counter = 1; while (guessNumber != number) { // get a valid int from user guessNumber...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT