Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You will write a short Java application that will accept five strings from the u

ID: 674995 • Letter: Y

Question

You will write a short Java application that will accept five strings from the user. Each String will be a word in a sentence. The first word will be a subject, the second word will be a verb, the third word will be an adjective, the fourth word will be an object, and the fifth word will be an adverb. After all five words are entered, display the sentence using the following form: Subject - Verb - Adjective - Object - Adverb. Take a screenshot to verify that your sentence is displayed successfully

Explanation / Answer

package shoutbox;

import java.util.Scanner;

import java.util.Scanner;

/**

*

* @author

*/

public class ShoutBox {

    private static Object scanner;

    public static void main(String[] args) { // main method

            shoutOutRandomMessage();

        }

    public static void shoutOutRandomMessage() {       

        String shoutSubject;

        String shoutObject;

        String shoutVerb;

        String shoutAdverb;

        String shoutAdjective;

         

        int length; // instance variable that determines the length of the array

        Scanner input = new Scanner(System.in); // the Scanner utility is added

         

        System.out.println("You may choose how many words you want to enter. "

                           + "Please write a number between 1 and 100 and hit Enter: ");

         

        length = input.nextInt(); // takes user input of integer

        int number = 0;

         

        // create array to store user words

        String[] subject = new String[length];

         

        for(int counter = 0; counter < length; counter++){

        System.out.println("Please enter Subject " + (counter+1) + ": ");

        subject[counter] = input.next(); // reads user input and stores the words in array

        }

         

        System.out.println("The Subjects of your choice are: ");

         

        for(int counter = 0; counter < length; counter++){

        System.out.println(subject[counter]);

        }

           // create array to store user words

        String[] object = new String[length];

         

        for(int counter = 0; counter < length; counter++){

        System.out.println("Please enter Object " + (counter+1) + ": ");

        object[counter] = input.next(); // reads user input and stores the words in array

        }

         

        System.out.println("The Objects of your choice are: ");

         

        for(int counter = 0; counter < length; counter++){

        System.out.println(object[counter]);

        }

         

           // create array to store user words

        String[] verb = new String[length];

         

        for(int counter = 0; counter < length; counter++){

        System.out.println("Please enter Verb " + (counter+1) + ": ");

        subject[counter] = input.next(); // reads user input and stores the words in array

        }

         

        System.out.println("The Verbs of your choice are: ");

         

        for(int counter = 0; counter < length; counter++){

        System.out.println(verb[counter]);

        }

         

           // create array to store user words

        String[] adverb = new String[length];

         

        for(int counter = 0; counter < length; counter++){

        System.out.println("Please enter Adverb " + (counter+1) + ": ");

        adverb[counter] = input.next(); // reads user input and stores the words in array

        }

         

        System.out.println("The Adverbs of your choice are: ");

         

        for(int counter = 0; counter < length; counter++){

        System.out.println(adverb[counter]);

        }

         

           // create array to store user words

        String[] adjective = new String[length];

         

        for(int counter = 0; counter < length; counter++){

        System.out.println("Please enter Adjective " + (counter+1) + ": ");

        adjective[counter] = input.next(); // reads user input and stores the words in array

        }

         

        System.out.println("The Adjectives of your choice are: ");

         

        for(int counter = 0; counter < length; counter++){

        System.out.println(adjective[counter]);

        }

         

       // retrieve random number that equals index and returns array element

        int random = (int) (Math.random()*length);

        int i = 0;

        System.out.println( random == i);

        subject[random] = subject[i]; // <<<<<<<<<<<<<------- I am lost

        object[random] = object[i];                                                                                                          

        verb[random] = verb[i];                                                                                                                

        adverb[random] = adverb[i];                                                                                                         

        adjective[random] = adjective[i];                                                                                                   

        String message;                                                                                                                            

        message[i] = subject[i], object[i], verb[i], adverb[i], adjective[i];   

         

        System.out.print(<message>.toString());

        }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote