Question

In: Computer Science

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 rest of the characters displaying a * instead of the character,

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

    Based on the previous specifications your program should behave and look exactly as shown in the cases below. Your program should work for any word entered by the user, not just the ones in the samples.

    Below illustrates how your program should behave and appear.

    Note that ◦ symbol indicates a space and ↵ is a new line character. All words except for user input (in blue) must be exactly as indicated in the sample. Any extra “spaces” and/or “new lines” will be graded a wrong answer.

        

Solutions

Expert Solution

Source Code:

import java.util.Scanner;

class ex
{
   public static void main(String[] args) {
       Scanner input=new Scanner(System.in);
       System.out.print("Enter a word: ");
       String word=input.next();
       String org=word;
       word=word.toUpperCase();
       System.out.println('"'+word+'"');
       word=word.toLowerCase();
       for(int i=0;i<word.length();i++)
       {
           if(i%2==0)
               System.out.print("*");
           else
               System.out.print(word.charAt(i));
       }
       System.out.println();
       System.out.println(org);
   }
}

Sample input and output:


Related Solutions

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...
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...
Write a java program that read a line of input as a sentence and display: ...
Write a java program that read a line of input as a sentence and display:  Only the uppercase letters in the sentence.  The sentence, with all lowercase vowels (i.e. “a”, “e”, “i”, “o”, and “u”) replaced by a strike symbol “*”.
4. (20 marks) A English word is palindrome if its characters read the same backward as...
4. A English word is palindrome if its characters read the same backward as forward. For example, civic is palindrome. Describe a recursive algorithm for determining a word w of length n is palindrome or not. Analyze its time complexity using a recursion tree. Implement your algorithm in Java
Write a C++ program to read characters from the keyboard until a '#' character is read....
Write a C++ program to read characters from the keyboard until a '#' character is read. Then the program will find and print the number of uppercase letters read from the keyboard.
Write a JAVA program read a number within the range of 1 through 1000 to display...
Write a JAVA program read a number within the range of 1 through 1000 to display the Roman numeral version of that number. Include screenshot of the output
JAVA. A palindrome is a word or a phrase that is the same when read both forward and backward.
java please. A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob," "sees," or "never odd or even" (ignoring spaces). Write a program whose input is a word or phrase, and that outputs whether the input is a palindrome.Ex: If the input is:bobthe output is:bob is a palindromeEx: If the input is:bobbythe output is:bobby is not a palindromeHint: Start by removing spaces. Then check if a string is equivalent to it's reverse.Hint: Start by just handling single-word...
A palindrome is a string of characters (a word, phrase, or sentence) that is the same...
A palindrome is a string of characters (a word, phrase, or sentence) that is the same regardless of whether you read it forward or backward – assuming that you ignore spaces, punctuation and case. For example, Race car is a palindrome. So is A man, a plan, a canal: Panama. 1. Describe how you could use a stack to test whether a string is a palindrome. 2. Describe how you could use a queue to test whether a string is...
In java, ask the user for a filename. Display the oldest car for every manufacturer from...
In java, ask the user for a filename. Display the oldest car for every manufacturer from that file. Files Given: car-list.txt car-list-1.txt car-list-2.txt car-list-3.txt (they are too big for question) Required Output: Standard Input                 Files in the same directory car-list-1.txt car-list.txt car-list-1.txt car-list-2.txt car-list-3.txt Enter filename\n Oldest cars by make\n Acura Legend 1989 2T1BPRHE8EC858192\n Audi 80/90 1988 2GKALMEK4E6424961\n Bentley Continental Flying Spur 2006 WBA3G7C5XFK430850\n BMW 600 1959 1N6AA0ED2FN639969\n Bugatti Veyron 2009 SCFEBBBC5AG474636\n Buick Century 1987 2HNYD18625H455550\n Cadillac DeVille 1994...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT