1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kirill115 [55]
3 years ago
14

Write a fragment of code that will read words from the keyboard until the word done is entered. For each word except done, repor

t whether its first character is equal to its last character. For the required loop, use a:_________.
a) while statement.
b) do-while statement.
Computers and Technology
1 answer:
hram777 [196]3 years ago
8 0

Answer:

a)

Scanner keyboard = new Scanner(System.in);

System.out.println("Enter a word");

String word = keyboard.next();

while(!word.equals("done"))

{

if(word.charAt(0) == word.charAt(word.length() - 1))

{

System.out.println("First and last character are equals for the word: " + word);

}

else

{

System.out.println("First and last character are NOT equals for the word: " + word);

}

word = keyboard.next();

}

b)

Scanner keyboard = new Scanner(System.in);

System.out.println("Enter a word");

String word = keyboard.next();

do

{

if(word.charAt(0) == word.charAt(word.length() - 1))

{

System.out.println("First and last character are equals for the word: " + word);

}

else

{

System.out.println("First and last character are NOT equals for the word: " + word);

}

word = keyboard.next();

}while(!word.equals("done"));

Next time note what language you are distributing programming with :)

You might be interested in
# q7 - create function readFileFirstLast() to meet the conditions below
MAVERICK [17]

Answer:

See explaination

Explanation:

def readFileFirstLast(filename):

# doc string

''' Function accept the filename and opens the fle

and reads all lines and strips new line character and

stores first and last in a string and return that string'''

#eception handle if file not found

try:

#opening the file

f = open(filename)

#reading the first line and striping the ne line

string = f.readline().strip()

#iterating until last line

for line in f:

pass

#concate the last line after strip the new line character to the string

string = string + " " + line.strip()

#return the string

return string

except:

#if file not found

return "File not found"

#taking the file name from user

filename = input("Enter a file name: ")

#printing the doc string in function

print("\ndoc_sting: \n"+ readFileFirstLast.__doc__+"\n")

#printing the returned string by calling the readFileFirstLast()

print("output string :")

print(readFileFirstLast(filename))

3 0
3 years ago
Ryan wants to ensure that all the words in this document are evenly spaced so that they look neat and readable . Which option in
natka813 [3]
To achieved a document that is evenly spaced so that they look neat and readable, the option in a word processing program will help to achieve this is the home setting. In the home of the word, you can see there various tabs, one of the tabs is the paragraph. You will click symbol of "justify". And there is simple code to do that, just press the "Ctrl" and "J" on your keyboard at the same time.
5 0
3 years ago
PLEASE HELP!!<br> Would you ever try and get famous off of social media? Why or why not?
Alexxandr [17]

Answer:

Yes because u could gain a lot of money from it

Explanation:

With more money you have, the more you can give to charity, and the more you can relax

3 0
2 years ago
Read 2 more answers
How many total numbers can be represented with an 8-bit binary (base-2) system?
ddd [48]

Answer:

256

Explanation:

4 0
3 years ago
WILL GIVE BRAINLIEST!!!!!!!!!
sukhopar [10]

Answer:

True

Explanation:

7 0
3 years ago
Other questions:
  • What might be one reason why a stock becomes more valuable over time
    5·1 answer
  • What happens if you move unencrypted files into an encrypted folder?
    5·1 answer
  • Que funcion tiene la sombrilla forrada de aluminio​
    6·1 answer
  • A user clicked an email link that led to a website than infected the workstation with a virus. The virus encrypted all the netwo
    10·1 answer
  • _____ involves storing data and running applications outside the company’s firewall. answer grid computing parallel computing cl
    11·1 answer
  • Anyone know how to delete it in my laptop
    10·1 answer
  • Assume that class BankAccount exists, and that it has a constructor that sets the private field balance, and that setBalance and
    13·1 answer
  • How does the autosum command calculate data? Need help ASAP​
    5·1 answer
  • Where would you go to access frequently used icons?
    12·2 answers
  • Providing captions and transcripts for videos on your website is a way of ensuring what?.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!