Question

In: Computer Science

Read this entire document before beginning your lab. For this lab you are required to fulfill...

Read this entire document before beginning your lab.

For this lab you are required to fulfill all requirements exactly as described in this provided document, no less, no more.

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 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.

        

Program Sample outputs

ex:1

Enter◦a◦word:◦ELEPhant↵ ↵
"ELEPHANT"↵
*l*p*a*t↵

ELEPhant

ex:2

Enter◦a◦word:◦Nancy_12A↵ ↵
"NANCY_12A"↵ *a*c*_*2*↵

Nancy_12A

Note 1: The use of libraries other than java.util.Scanner is prohibited.
Note 2: You may find the use of the following methods useful – charAt(), toLowerCase(), toUpperCase(), length().

in java

Note 3: Final thought, remember that your solution is case-sensitive and space-sensitive, fulfill the above instructions carefully and precisely.

Solutions

Expert Solution

Code:

import java.util.Scanner;
public class Main
{
   public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
       System.out.print("Enter a word: ");
       String a=sc.nextLine();
       int n=a.length();
       String u=a.toUpperCase();
       u="\""+u+"\"";
       String l=a.toLowerCase();
       String s="";
       for(int i=0;i<n;i++)
       {
       char x=l.charAt(i);
       if(i%2==0)
       s=s+"*";
       else
       s=s+x;
       }
       System.out.print("\n"+u+"\n"+s+"\n"+a);
   }
}

Please refer to the screenshot of the code to understand the indentation of the code:

Outputs:

1.

2.

For any doubts or questions comment below.


Related Solutions

PLEASE READ ALL OF THESE INSTRUCTIONS BEFORE BEGINNING THIS ASSIGNMENT. For this assignment, you need to...
PLEASE READ ALL OF THESE INSTRUCTIONS BEFORE BEGINNING THIS ASSIGNMENT. For this assignment, you need to analyze the information below from BOTH the management AND the employee perspective. This information pertains to a labor union in a simulated/made up/not real firm in Glen Ellyn. The first part of your information relates to Management – the second part relates to the Labor Union employees. I have provided you with information from the last union negotiations at the plant in 2016. It...
Read the following document to answer the question: (use the document to support your idea as...
Read the following document to answer the question: (use the document to support your idea as a reference since I'm using the answer to complete my paper, please) How working both 8 hour and 12 hour nursing shift impact the negligence and malpractice at work if you are working as a nurse? Negligence and malpractice There are two types of torts: an unintentional tort (or wrong) and an intentional tort. An unintentional tort is an unintended wrong against another person....
Read the following document to answer the question: (use the document to support your idea as...
Read the following document to answer the question: (use the document to support your idea as a reference since I'm using the answer to complete my paper, please) How working both 8 hour and 12 hour nursing shift impact the accountability at work if you are working as a nurse? The challenge of accountability A host of specific ethical issues exists within the practice of nursing itself. Professional nursing is a complex profession that is unlike most others. The accountability...
I appreciate your help! 1. Generally, if the owner of an IRA dies before beginning required...
I appreciate your help! 1. Generally, if the owner of an IRA dies before beginning required minimum distributions, the designated beneficiary must: A. Take the entire amount in lump-sum in the year after the year of death. B. Take the required minimum distributions for the years after the year of death. C. Take the entire amount within five years after the year of death. D. Begin to take the required minimum distributions when the beneficiary turns 70½. 2. James, who...
Please read through the entire question before answering. I'm asking for assistance on how to calculate...
Please read through the entire question before answering. I'm asking for assistance on how to calculate LOSS, not gain. Thank you! The major stock market indexes had strong results in 2014. The mean one-year return for stocks in the S&P 500, a group of 500 very large companies was +11.4%. The mean one year return for the NASDAQ, a group of 3200 small and medium-sized companies was +13.4%. Historically, the one-year returns are approximately normal, the standard deviation in the...
To prepare for this Discussion, you will be required to read the assigned chapters in your...
To prepare for this Discussion, you will be required to read the assigned chapters in your Stanhope and Lancaster text. Then, call the Department of Health or your local Public Health Department and speak to a nurse. Find out the top health concern(s) for your community. Please focus your attention on the unique tools that nurses who work in the community utilize to care for populations, including the Intervention Wheel. Please listen to Dr. Attia’s Ted Talk in the resources...
Start an FC-PC Lab Assignment document and save it to your drive. Note: As you complete...
Start an FC-PC Lab Assignment document and save it to your drive. Note: As you complete the below exercises add them to your Assignment document and save it Create the algorithms in both flowchart and pseudocode form for the following two program requirements:   Given is the array prices with 100 elements(prices[100]). The problem consists of two parts:  1. Find the highest price in the array; and  2. Reduce that price by 10% For any three numbers input by the user, output the...
As a lab instructor in machining, you are required to prepare a lab module for a...
As a lab instructor in machining, you are required to prepare a lab module for a laboratory session with your students. In this session, the students are required to produce aT-Slot. Prepare the methodology to produce the T -Slot with illustrations for the lab module.
Read the assignment and answer the questions. You must also upload your Excel file, Word document...
Read the assignment and answer the questions. You must also upload your Excel file, Word document or pdf showing your work. Bodacious Building Co. is considering four different acquisition methods for obtaining pickup trucks. If the contractor’s MARR is 6%, which alternative do you recommend? The alternatives are: Immediate cash purchase of the trucks for $22,500 each, and after five years sell each truck for an estimated $4,900. Lease the trucks for five years for $4,000 per year paid at...
What was your attitude about investments before and after you read the chapter on investments?
What was your attitude about investments before and after you read the chapter on investments?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT