Question

In: Computer Science

Problem: Read in a word and display the requested characters from that word in the requested...

Problem: Read in a word and display the requested characters from that word in the requested format. Write a Java program that

● prompts the user for a word and reads it,

● converts all characters of the input word to uppercase and displays every other character starting from the 1st one,

● converts all characters of the input word to lowercase and displays every other character in reverse order starting from the last character,

● finally displays the original word as it was entered by the user.

Solutions

Expert Solution

ANSWER:--

GIVEN THAT:--

import java.util.Scanner;

public class Main
{
   public static void main(String[] args) {
       Scanner myObj = new Scanner(System.in); // Create a Scanner object

        System.out.print("Input The Word : ");
        String word = myObj.nextLine(); // original word

        String tempword = new String(word); // temporary storage

        tempword = tempword.toUpperCase();

        System.out.print("\nThe word in CAPS : ");
        for (int i = 0; i < tempword.length(); i += 3)
            System.out.print(tempword.charAt(i));

        tempword = tempword.toLowerCase();

        String rev = "";

        for (int i = tempword.length() - 1; i >= 0; --i)
            rev += tempword.charAt(i);

        System.out.print("\nThe word in reverse : ");
        System.out.print(rev);

        System.out.print("\nThe original word : ");
        System.out.print(word);

        myObj.close();
   }
}


Related Solutions

in java Read in a word and display the requested characters from that word in the...
in java Read in a word and display the requested characters from that word in the requested format. Write a Java program that ● prompts the user for a word and reads it, ● converts all characters of the input word to uppercase and display the word with a double quotation mark ( " ) at the start and end of the word, ● displays the word with all characters whose index is odd in lower case and for the...
Design an algorithm that will read an array of 200 characters and display to the screen...
Design an algorithm that will read an array of 200 characters and display to the screen a count of the occurrences of each of the five vowels (a, e, i, o, u) in the array. Your string is: The quick brown fox jumped over the lazy dog That is the question for my pseudo code question, I don't know if I have this correct can i have someone look this over and finish this and explain what i needed to...
In Java. Modify the attached GameDriver2 to read characters in from a text file rather than...
In Java. Modify the attached GameDriver2 to read characters in from a text file rather than the user. You should use appropriate exception handling when reading from the file. The text file that you will read is provided. -------------------- Modify GaveDriver2.java -------------------- -----GameDriver2.java ----- import java.io.File; import java.util.ArrayList; import java.util.Scanner; /** * Class: GameDriver * * This class provides the main method for Homework 2 which reads in a * series of Wizards, Soldier and Civilian information from the user...
Part 1 Write a program that reads a line of input and display the characters between...
Part 1 Write a program that reads a line of input and display the characters between the first two '*' characters. If no two '*' occur, the program should display a message about not finding two * characters. For example, if the user enters: 1abc*D2Efg_#!*345Higkl*mn+op*qr the program should display the following: D2Efg_#! 1) Name your program stars.c. 2) Assume input is no more than 1000 characters. 3) String library functions are NOT allowed in this program. 4) To read a...
Write a program that prompts the user to enter two characters and display the corresponding major...
Write a program that prompts the user to enter two characters and display the corresponding major and year status. The first character indicates the major. And the second character is a number character 1, 2, 3, 4, which indicates whether a student is a freshman, sophomore, junior, or senior. We consider only the following majors: B (or b): Biology C (or c): Computer Science I (or i): Information Technology and Systems M (or m): Marketing H (or h): Healthcare Management...
Create a program in C that counts the number of characters in a word when a...
Create a program in C that counts the number of characters in a word when a user inputs a string. Use stdin to read an input string. For example, if a user inputs: “The dog is good” the output should be a= [The], b=3 a= [dog], b=3 a= [ is], b=2 a= [good], b=4 a= [ ], b=0000 Take into account EOF. If an EOF is reached at the end of the string then the output should be 0000. (example...
Create a program in C that counts the number of characters in a word when a...
Create a program in C that counts the number of characters in a word when a user inputs a string. Use stdin to read an input string. For example, if a user inputs: “The dog is good” the output should be a= [The], b=3 a= [dog], b=3 a= [ is], b=2 a= [good], b=4 a= [ ], b=0000 Take into account EOF. If an EOF is reached at the end of the string then the output should be 0000. (example...
Introduction This program will read from a file containing inventory data, and display summary information to...
Introduction This program will read from a file containing inventory data, and display summary information to the user. Instructions and Information For this project, input will be from file, and output will be to standard output (the console). The file will be read, and the information stored in the appropriate data format and data structure. Then, the inventory data will be printed out, listing the frequency of each item next to its name. The frequency means the combined sum of...
hello everyone it is requested from me to it is requested from me to make a...
hello everyone it is requested from me to it is requested from me to make a presentation about the (( application of energy dissipation analysis in dynamics of structures )) can you help by providing some information my greetings
Note : the Answer should be computerized , in Word format The student is requested to...
Note : the Answer should be computerized , in Word format The student is requested to select a very simple business, one with a single product. Some possibilities are: A child’s lemonade stand A retail DVD rental store A coffee shop A retail store selling compact discs An athletic shoe store A cookie stands in a mall However, you are encouraged to use your imagination rather than just select one of these examples. After, please complete the following tasks: 1.    Make...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT