PLEASE HELP asap 60 POINTS
needs to be in Java

A programmer has written a method called replaceLetter that counts the amount of times a letter is present in a word. Your job is to modify this existing method to fulfill a new purpose.

Rather than count the instances of a letter in a String, write a program that replaces all instance of one letter with another. You should directly modify replaceLetter to get this program to work. In the starter code, replaceLetter only has two parameter values. Your new version should have a third parameter to indicate which String value is replacing the existing letter.

For example,

replaceLetter("hello", "l", "y")
returns

"heyyo"
Sample output:

Enter your word:
hello

Enter the letter you want to replace:
l

Enter the replacing letter:
x
hexxo
Hint: The letters will be assigned from the user as String values. Make sure to use String methods to compare them!

Answers

Answer 1

import java.util.Scanner;

public class JavaApplication45 {

   public static String replaceLetter(String txt, String txt1, String txt2 ){

       char one = txt1.charAt(0);

       char two = txt2.charAt(0);

       String newTxt = "";

       for (int i = 0; i < txt.length(); i++){

           char c = txt.charAt(i);

           if (c == one){

               newTxt += two;

           }

           else{

               newTxt += c;

           }

       }

       return newTxt;

   }

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       System.out.println("Enter your word:");

       String word = scan.nextLine();

       System.out.println("Enter the letter you want to replace:");

       String txt1 = scan.next();

       System.out.println("Enter the replacing letter:");

       String txt2 = scan.next();

       System.out.println(replaceLetter(word,txt1,txt2));

   }

   

}

I hope this helps!


Related Questions

If you're driving a car and know there's a motorcyclist around you, you should______. A. Not change your driving B. Check your blind spots frequently C. Remind them to wear a helmet D. Make wider turns than normal

Answers

b check your blind spots frequently i guess not sure

Select the correct answer from the drop-down menu.
Chrissie shirks the additional work given to her.
She lacks the trait of

Answers

Answer:

Responsibility

Explanation:

Which of the following expressions shows the correct amount of sales tax for the computer at Store A? Select all that apply.
6%($1,200)
0.6($1,200)
0.06($1,200)
One-sixth($1,200)
StartFraction 3 over 50 EndFraction($1,200)

Answers

Answer:

6%($1,200)  0.06($1,200)  3/50($1,200)

Explanation:

hope this helps sorry if i am wrong

have a nice day

Answer:

a,c,e

Explanation:

it just makes sense U^U

Any application that wants to be displayed on the web must use the HTTP protocol
True
False

Answers

Answer:

true

Explanation:

how to take a pic with a cumputer

Answers

Answer:

Ctrl+Shift+4

Explanation:

Answer:

Use Snip+Sketch on your taskbar

It looks like this~

Stay at least _____ behind the vehicle ahead of you at all times.
A. 3 seconds
B. 4 seconds
C. 3 car lengths
D. 4 car lengths

Answers

Answer:

B 4 seconds

Explanation:

You should stay 4 seconds away from a vehicle at all times at the same speed as the other vehicle or vehicles.

B
You should stay 4 seconds away from a car

CSS is a language that controls the way content on a web site appears. It uses_______ _____to
change the look of a page.

Answers

Answer:

I'm not sure what the answers are, but when someone is making a website from scratch, they tend to use CSS HTML and JS(javascript)

hope i helped ;)

Seneca has just applied conditional formatting and realizes that she has made a mistake. Which action should she take to fix the mistake?

A) Clear the rule she created by going to the Conditional Formatting Rules Manager dialog box and deleting the rule.
B) Clear all rules that have been applied to the worksheet or selected range by clicking the Clear Rules button.
C) Use the Undo button or Ctrl+Z.
D) Right-click the area where the conditional formatting rule has been applied, and select Clear Rule from the menu list.

Answers

Answer:

its b

Explanation:

on edg

Answer:

b

Explanation:

Which component in a CPU is responsible for transferring
data from one functional component to another?​

Answers

The data bus carries data from components to others

Who you think is better? Ninja or TFue ,btw do you know who icebear is?

Answers

Answer:

no, no i dont think i will.

Explanation:

What does it mean to be proactive about internet safety?
Spending as little time online as possible to reduce the risk of problems.
Predicting problems before they happen so you can avoid them.
Finding the best way to solve a current problem so you can use it later.
Facing up to the consequences of your mistakes so you can learn from them.

Answers

Answer:

Predicting problems before they happen so you can avoid them.

Explanation:

You should avoid causing trouble, or partaking in it. Being safe on the internet helps reduce bullying, threats, depressing behavior, etc.

I do agre the answer is shoving a stick in dirt

¿En cuales situaciones concretas se puede aplicar las técnicas de conteo(particularmente las permutuaciones y las combinaciones) dentro de la informática?

Answers

Answer:

In which specific situations can counting techniques (particularly permutuations and combinations) be applied within computer science? for anybody trying to help

What are the characteristics of calendar sharing options in Outlook 2016? Check all that apply.

Answers

Answer:

a,b,c,e

Explanation:

Answer:

Quit your bickering in the replies on the other answer, this is correct.

Explanation:

Which of the following is true of functions? * 2 points A. Programs written with functions run more quickly B. Functions can help remove repeated code from a program C. Replacing repeated code with a function will reduce the number of commands the computer needs to run D. Functions are called once but can be declared many times

Answers

Answer:

I’m sure if I remember that this is “B.”

Explanation:

I have taken computer science class before so I remembered!

The option that is true of functions is B. Functions can help remove repeated code from a program.

It should be noted that the fact that programs are written with functions doesn't mean that they will run quickly.

Functions can help remove repeated code from a program. Also, replacing repeated code with a function doesn't reduce the number of commands the computer needs to run.

Read related link on:

https://brainly.com/question/17691320

A collection of computers, printers, routers, switches, and other devices
that can communicate with each other over some transmission medium
O network
O host part
subnet part
subnet

Answers

ermano envia foto de lo que necesitas yo te ayudo

Umm, my computer is being rlly wierd and not letting me give brainliest to someone, anybody know what to do???

Answers

- Try restarting the device
- Use another device
- Re-install/Refresh your brainly page
- Wait for the issue to be gone
- Try doing it again
- Quit+Rejoin the app

Answer:

just restart it and when the computer is done restarting then repeat the process once more. This is what i did and it made a huge difference.

Explanation:

This resets the main hard drive and the reboots the system entirely. It helps clear out bugs and fixes any and all small issues.

Which term means an unsecure protocol used when remotely accessing a computer?

Transmission Control Protocol (TCP)
Secure Shell (SSH)
Telnet
Internet Protocol (IP)

Answers

Answer:

9Internet Protocol (IP)

Answer:

The answer is Secure Shell (SSH)

Jon wants to set up a trihomed DMZ. Which is the best method to do so? A. use dual firewalls B. use a single firewall with only two interfaces C. use a single three-legged firewall with three interfaces D. use dual firewalls with three interfaces

Answers

Answer:

The correct option is C) Use a single three-legged firewall with three interfaces

Explanation:

DMZ is an acronym for a demilitarized zone.

A DMZ network is one is situated between the internal network and the Internet. It is supported by an Internet Security and Acceleration (ISA) server.

The interfaces you'd get with the DMZ network are

A public network (Internet Protocol-IP) address  with a public interfaceAn internal network interface with a private network (IP) address  A DMZ interface with a public network (IP) address  

Unlike the back-to-back DMZ settings, a trihomed DMZ is unable to use private IP addresses. To use the trihomed DMZ, public IP addresses are a must suitable requirement.

Cheers!

Identify an advantage of writing HTML code manually.

You do not have to learn HTML.

You can figure out how the markup affects the function of the site.

You can see rendered HTML as you go.​

Answers

Answer:

1. You retain 100% control over your site and where it is hosted

2. Free WYSIWYG sites aren’t really free

3. You make yourself seem irrelevant to clients

4. You understand your own code

5. Your own code is nearly always more efficient

6. Your own code is more secure

7. It’s easier to iterate your own code

8. Your own code is original

9. Writing your own code helps you grow as a developer

Explanation:

You can choose the points you want. let me know if you need any further information.☺️

Please rate if you happy

Brailliest if you want

Answer:

B. You can figure out how the markup affects the function of the site.

Explanation:

its the correct answer :)

"prevention is better than cure" Justify this statment.​

Answers

Answer:

Hope

you like it and helpful

In a science study group, Leonardo explains how atoms make up molecules. Talia repeats what Leonardo says in her own words. How is Talia practicing active listening? She is reflecting on what has been said. She is politely disagreeing with Leonardo. She is asking Leonardo a lot of questions. She is focused on only important information.

Answers

Answer:

A she is reflecting on what leonardo said but in her own words

Explanation:

Answer:

A: She is reflecting on what has been said.

Explanation:

Edge 2020

Need answer Asap!!!! Which file type is the best choice if the image will be made into a billboard?

Answers

Answer:

A .psd file

Explanation:

Adobe photoshop files are always going to be same and there is no compression. Even better .ai files are saved into equations so you can't alter or dumb it down.

WHERE DO I GO TO DO THIS AND WHAT DO I WRITE?????
Write a pseudocode plan for your program.
Write the code for your program.
Test your program. Run it at least three times with different inputs.
Save your program as a .txt file for you cannot upload a .py file.
Evaluate your project using this rubric.
What to Submit
Submit the .txt file holding your program.

Answers

You can just look up "python ide online" on google and paste this code:

n = -1

count = 0

while n < 0:

   n = int(input("We're checking to see if a number is prime or not! Enter a positive number: "))

if n % 2 == 0:

   if n == 2:

       print("{} is a prime number".format(n))

   else:

       print("{} is not a prime number".format(n))

else:

   for x in range(n, 1, -1):

       if n % x == 0:

           count += 1

   if count > 1 or n == 1:

       print("{} is not a prime number".format(n))

   else:

       print("{} is a prime number".format(n))

I've written some code that checks to see if a number entered by the user is a prime number or not.

Sorry, but I'm not too good with pseudocode plans and all that. I hope this helps.

Answer:

import math

print("Let's solve ax² + bx + c = 0")

a = int(float(input('Enter a value for a: ')))

b = int(float(input('Enter a value for b: ')))

c = int(float(input('Enter a value for c: ')))

D = b*b-4*a*c

if (D<0):

   print("Sorry, this equation has no solutions.")

elif (a == 0):

   if (b == 0):

       if (c == 0):

           print("Every value of x is a solution")

       else:

           print("Sorry, this equation has no solutions")

   else:

       x = -c/b

   print("The one solution is x={:.3g}".format(x))

elif (D==0):

   x = (-b + math.sqrt(D)) / (2*a)

   print("The one solution is x={:.3g}".format(x))

else:

   x1 = (-b + math.sqrt(D)) / (2*a)

   x2 = (-b - math.sqrt(D)) / (2*a)

   print("This equation has two solutions: x={:.3g} or x={:.3g}".format(x1, x2))

Explanation:

Above is another little program to use the quadratic formula.

Select all the lines that have a slope of 5/2

Answers

Answer:

Add a picture, then ask the question again.

The Quick Access tool bar allows you to customize the actions or commands you frequently use.

True
False

Answers

I believe its true.

I need help pleaseeee

Answers

Answer:

The Answer is C. Hope you get it right, Good Luck!!!

Answer:

The answer is B

Explanation:

To create a list, paragraph, or unordered list, you should use HTML code, whereas in CSS coding, you can change the overall font size of a tag using the font-size=(number) tag.

Question 5 of 25
Critics argue that socializing online:
O A. makes us socially savvy and aware.
B. limits the number of posts we read.
C. dilutes the quality of our relationships.
O D. decreases a user's popularity.

Answers

Answer: d

Explanation; Hopes this helps!!

Critics argue that socializing online dilutes the quality of our relationships. Thus, option C is correct.

What is socializing online?

Online socializing refers to the exchange of information between individuals or groups that uses social media platforms to access and alter material including photos, status updates, music, videos, and more.

Socialization on the Internet describes how individuals communicate and the tools they employ to do so. Socialization refers to a culture's peculiar practices, dialect, and language.

They can increase understanding of already-held interests while introducing young people to new concepts and ideas. Additionally, by assisting users in learning about various cultures' ways of life and thinking, they can help users widen their perspectives.

Online socializing, according to critics, degrades the caliber of our connections. Option C is correct as a result.

Learn more about online here:

https://brainly.com/question/19546714

#SPJ5

Justify the use of an e-diary in the organisation of the meeting.

Answers

Answer:

It can be used to easily organize stuff

Explanation: It can be easily used to organize meetings & write important stuff, and you will also never run out of pages, which is better than having no diary.

The complete process for learning through repetition is to read, write, say, rest and revisit the information. Please select the best answer from the choices provided T F

Answers

Answer:

True.

Explanation:

The complete process for learning through repetition is to read, write, say, rest and revisit the information.

This ultimately implies that, when an individual indulge in learning through repetition, he or she would is strengthening the single memory trace and as such enhancing the learning process.

Hence, learning through repetition such as reading, writing, saying, resting and revisiting the information is very effective because it engages and activates the visual, auditory, tactile and kinesthetic neural pathways to the brain.

Additionally, it is advisable to wait for about ten (10) minutes in between the repetition process when learning through repetition.

Answer:

True

Explanation:

Just took the quiz.

HELP!!!!!
Your colleague has made a suggested change to an important document you are both working on. You disagree with their suggested change. They will be reviewing the changes you make before the final version of the document is submitted to your boss. You both work remotely and are in radically different time zones. What is the best step to take next?

Answers

Leave the room and let someone else figure it out!
Other Questions
Please help me!Find the slope of the line on the graph.Write your answer as a fraction or a wholenumber, not a mixed number or decimal.Enter the correct answer Should graffiti be illegal, yes or no? Give reasons or evidence to support your claim. If m Which of the following equations is not balanced? What is the lcm of 9,18 and99 Revenue recognition over time and at a point in time under ASC Topic 606 (LO3-4) MSK Construction Company contracted to construct a factory building for $525,000. Construction started during 20X1 and was completed in 20X2. Information relating to the contract follows: 20X1 20X2 Costs incurred during the year $290,000 $150,000 Estimated additional cost to complete 145,000 Billings during the year 260,000 265,000 Cash collections during the year 240,000 285,000 Required: 1. Record the preceding transactions in MSKs books assuming it recognizes revenue over time and uses costs incurred to measure the extent to which its performance obligation has been satisfied. 2. Record the preceding transactions in MSKs books assuming it recognizes revenue at a point in time when control of the completed factory is transferred to the customer at the end of the project. Write only a paragraph on how to write the decalration of independence? which theme of Sir Arthur Conan Doyle's the adventure of the speckled band is expressed in this excerpt of the storyA. the importance of proof and logicB. the dangers of jumping to conclusions C. good versus evilD. England fascination with East how does the modern-day idea of what the Crusades were differ from the true history of theCrusades? Definition of HIV and AIDS B. Mettez les propositions affirmatives au ngatif. (punei propoziiile afirmative la negativ ). Il joue au football. 10 puncte Tu regardes la TV. 10 puncte C. Ecrivez la forme correcte du verbe en parenthses, correspondante chaque personne. (Scriei forma corect a verbului din parantez, corespunztoare cu persoana dat pentru a completa propoziiile de mai jos.) 1. L'enfant ........................................ Dans l'escalier. (tomber) 10 puncte 2. Tu m' ton cahier. (apporter) 10 puncte 3. Tu .. Beaucoup d'argent. (gagner) 10 puncte 4. Il ............................................... Des rparations. (executer) Which type of pronoun is hers in the sentence "The poster about the planets is hers."?A.)objectiveB.)possessiveC.)interrogativeD.)subjective All living organisms are composed of: Laura checked her outdoor thermometer and noticed that the temperature rose from 31 degrees in the morning to 45 degrees in the afternoon. What is the approximate percent increase for the day so far?A. The percent increase is approximately 31%.B. The percent increase is approximately 45%.C. The percent increase is approximately 68%.D. The percent increase is approximately 82%. What is the main function of the circulatory system in multicellular organisms? Scale is 1cm=8kmHatboro and Smithville are 24cm apart on the map. What is the actual distance between the 2 cities Plz Hurry This Is TimedWhat is the cycle of suffering, according to the Buddha? A.meditation and the finding of wisdom B.life and death, birth and rebirth C.enlightenment and the achievement of nirvana D.a desire for more things and for more wealth How can you influence art movement when being a singer? Find the approximate length of the track, including the straight and circular sections Which of the following phrases defines the word "export"? A. to send a product to another country to sell B. to purchase a product from another country C. to place taxes on goods purchased from other countries D. to limit how much of a good can come from other countries Please select the best answer from the choices provided B O D