TASK: Write a static method called repeatString that takes as input a String parameter word followed by an int parameter num. It should return a String that would be the result of repeating word exactly num times. If num is 0 or negative, the method should output an empty string.


HINT: Don't print out anything! Your method should return a string, not print it. print the output of your method behind the scenes to check that your method returns the right string; if you add your own print statements then the output won't be correct.


HINT: Make use of String concatenation!

Answers

Answer 1

Answer:

Follows are the method definition to this question:

public static String repeatString(String word, int num)//defining a String method repeatString that takes two parameters

{

   String Val= "";//defining String variable Val

   for(int x = 0;x<num;x++)//defining for loop to calculate number of string

   {

       Val=Val+word;//hold calculated value in Val

   }

   return Val;//return Val value

}

Explanation:

Follows are the full code to this question:

import java.util.*;//import package for user input

public class Main//defining class Main

{

   public static String repeatString(String word, int num)//defining a String method repeatString that takes two parameters

{

   String Val= "";//defining String variable Val

   for(int x = 0;x<num;x++)//defining for loop to calculate number of string

   {

       Val=Val+word;//hold calculated value in Val

   }

   return Val;//return Val value

}

public static void main(String[] ar)//defining main method

{

   int num;//defining integer variable

   String word; //defining String variable

   Scanner on=new Scanner(System.in);//creating Scanner class Object

   System.out.print("Enter numeric value: ");//print message

   num=on.nextInt();//input value

   System.out.print("Enter String value: ");//print message

   word=on.next();//input value

   System.out.print(repeatString(word,num));//call method and print its return value

}

}

Output:

Enter numeric value: 3

Enter String value: data

datadatadata

Description:

Inside the main class,  a static string method "repeatString" is defined that accepts two parameters "word and num", in which one is a string and one is an integer.

Inside the method, the string variable "Val" is defined, which uses the "for" loop to calculate the number of string and store its value in the variable.

In the main class, the above two variables are defined, that uses the Scanner class object for input the value and pass into the method and print its value.


Related Questions

Checking account a charges a mouthly service fee $23 and wire transfer fee of $7.50 while checking account b charges a monthly service fee of $14 and wire transfer fee of $9.50 which checking account is the better deal if four wire transfers are made per month

Answers

Answer:

Checking account b is the better deal, because the total monthly fees amount to $52, while those for checking account a amount to $53.

Explanation:

Given:

monthly service fee of checking account a = $23

wire transfer fee of a = $7.50

monthly service fee of checking account b = $14

wire transfer fee of b = $9.50

To find:

which checking account is the better deal if four wire transfers are made per month?

Solution:

If four wire transfers are made per month then total monthly fees of both accounts is computed as follows:

Account a:

service fee of a + four wire transfers fee of a

23 + 4(7.50) = 23 + 30 = $ 53

Account b:

service fee of b + four wire transfers fee of b

14 + 4 (9.50) = 14 + 38 = $ 52

From the above results checking account b is the better deal because the total monthly fees amount to $52 while total monthly fees for checking account a amount to $53.

Why can't you test a program for run-time errors when it has compile-time (syntax) errors

Answers

Answer:

your computer will not allow it

Explanation:

because it is not one of the main dyonostics

PLEASE HELP!! WILL MARK FIRST ANSWER BRAINLIEST!!~~~Amy needs to configure the Clutter option in Outlook 2016. Where should she go to activate the option?

Outlook Options
View tab
Outlook Web App
Ask an administrator

Answers

Outlook options I’m pretty sure

She needs to go enable the Outlook Options feature. Then, choice A is the best one.

What is the outlook?

The preferred email client for sending and receiving emails from Exchange Server 2010 is Microsoft Outlook. Accessibility to contact, mail, schedule, and task management systems is also provided by Outlook.

Microsoft Outlook is the electronic mail application for emails sent and received from Exchange Server by Microsoft. Outlook also makes contact, email, schedule, and activity management functions available.

In Outlook, select the File tab to access the backstage area; The Message Options dialogue box appears when you click the Info button in the left-hand menu after you've clicked the Properties button in the middle section.

She should go to activate the option will be Outlook Options. Then the correct option is A.

More about the outlook link is given below.

https://brainly.com/question/17457799

#SPJ6

What is the value of numC when this program is executed?
numA = 4
numB = 10
if numA == 2:
numC = 10
elif numA > numB:
numC = 20
else:
numC = 30

Answers

numA = 4 and numB = 10

for the if statement to run, numA has to equal 2, which it doesn't.

for the elif statement to run, numA has to be greater than numB, which it isn't.

That leaves the else statement, therefore, numC = 30

Answer:

30

Explanation:

what do you call the two parts of lift that go down a mine

Answers

The sheave wheel is a pulley wheel that sits above the mine shaft. The hoist cable passes over the sheave wheel and then down the shaft of the mine.
(copied from google)

A program for a computer is a “collection of code.”
True
False

Answers

Answer: true

Explanation: computer is all about code

Answer:

False, Took the test.

Why is computer called an information processing machine?

Answers

Answer:

A computer is an information processing machine. Computers process data to produce information. The sets of instructions that humans give computers are called programs or software. Computers never lose or misplace information.

hope this helped youuu:)

Search engines are used to find a specific entry in a database.

True or false?

Answers

True true true true I think

Answer:

True

Explanation:

My answer is true no explanation but i think its trueeeeeee

After the results of an experiment, a scientist decides that a long-held scientific theory must be revised. The scientist modifies the theory and tells other scientists. Predict the scientists' reaction, and explain why they might react that way. Your answer:

Answers

Answer:

Other scientists will be surprised at him/her

Explanation:

Science is totally empirical in its approach to knowledge. Models and theories are proposed and revised based on the available mass of experimental evidence.

However, all scientific findings must go through a rigorous process of verification and replication by other scientists in other parts of the world before they become  widely accepted in the world of science.

The scientist ought not to have modified the existing theory based on his findings as an individual. His findings ought to go through rigorous verification because other extraneous factors that he may not have controlled adequately may have led to the results he obtained.

Other scientists will be surprised and disregard his claims about the long held scientific theory until his findings are satisfactorily verified by other scientists working in different parts of the world.

I WILL GIVE BRAINLIEST TO WHO ANSWERS FIRST AND CORRECTLY.
Select the statements that describe working with text in presentation programs.

Working with text in presentation programs requires learning a new set of rules.
Working with text in presentation programs is similar to working with text in other applications.
The alignment of text in placeholders cannot be changed.
Font size and font color can be changed in presentations.
Audience size influences font size.

Answers

Answer:

Your answer is 1, 3, and 4.. Working with text in presentation programs requires learning a new set of rules, The alignment of text in placeholders cannot be changed, and Font sizes and color can be changed in presentations... Hope this helps!

Explanation:

what is digestion?
1. breathing
2.removing waste
3.breathing down food for energy
4.growing in size

Answers

Answer:

3

Explanation:

I'm assuming you mean " breaking" not "breathing"

Answer:

Digestion is the process of breaking down food for energy and creating waste

Explanation:

Which should be addressed by stakeholders when reviewing the problem statement? Select all that apply.

All possible outcomes have been thoroughly researched and rejected.

The problem as they see it has been addressed.

The solution proposed will meet their needs.

The needs of their colleagues are being met.

All issues and constraints have been identified.

Answers

The statement that should be addressed by stakeholders when reviewing the problem statement are the problem as they see it has been addressed, the solution proposed will meet their needs and all issues and constraints have been identified.

What are the elements of an effective problem statement?

An effective problem statement includes the description of the problem and the method that will be used to solve the problem.

The problem as they see it has been addressed, the solution proposed will meet their needs and all issues and constraints have been identified are the statement that should be addressed by stakeholders when reviewing the problem statement.

Therefore, B, C and E are the correct options.

Learn more about problem statement here:

https://brainly.com/question/11657822

#SPJ1

which of the following defines a network

Answers

A network, in computing, is a group of two or more devices or nodes that can communicate. The devices or nodes in question can be connected by physical or wireless connections. The key is that there are at least two separate components, and they are connected.

Samuel plans to use images of babies for a calendar. Which options should he choose?
A.
seek permission from the parents of the baby but do not mention the commercial use
B.
seek permission from no one, as it is the imageer’s duty to capture images
C.
seek permission from parents before using the baby’s image for commercial gains
D.
seek permission from the parents of the babies without telling them about where it will be used

Answers

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The correct option for this question is (C) -seek permission from parents before using the baby’s image for commercial gains

Because Samuel using images of babies for a calendar and use it for commercial purpose. So, she needs to seek permission from parents before using the baby's image for commercial gains. It is also required for her to tell babies' parents about the use of pictures commercially.  

Other options are not correct because legally and ethically she is bound to take permission from babies' parents before using it commercially.

Would X-ray waves carry a lot of energy? And do they have a high frequency?

Answers

Answer:

X-rays are very high frequency waves, and carry a lot of energy. They will pass through most substances, and this makes them useful in medicine and industry to see inside things.

I WILL GIVE BRAINLIEST TO WHO ANSWERS FIRST AND CORRECTLY.
How do you add text to a blank slide layout?

Select text from the Insert menu.
Click in the Task Pane and insert text.
You can't add text to a blank slide layout.
Draw a text box and enter text.

Answers

\The answer is B; Draw a text box and enter text

By default, we add text to a PowerPoint slide by typing it directly into a placeholder. However, you can use a text box to enter text into a blank slide or outside the placeholders. To add text on a blank slide click on the insert menu and select the Text box option. Click and hold down your mouse button while you drag the mouse. You will then clink inside the text box and starting typing.

Electronic medical charts make it easier for doctors to

share information on patients with other doctors.
share information on patients with the government.
communicate with patients about medical issues.
track infectious diseases through a database.

Answers

Answer:

Share information on patients with other doctors

Explanation:

Got it right on edge test

Answer:

Share information on patients with other doctors

Explanation:

Which of the following best describes the purpose of a design specification?

A. Tracking errors that arise through user testing
B. Documenting comments that will need to be added to a program
C. Describing the requirements for how a program will work or users will interact with it
D. Listing detailed questions that will be asked of users during interviews

Answers

Answer:

The correct option is;

C. Describing the requirements for how a program will work or users will interact with it

Explanation:

A design specification is the document that specifies how a program or system carries out the prerequisite tasks defined in the functional requirements information

The design specification outlines points, including factors concerning the functioning of the program, product, for the proper functioning of the program or product.

The design specification can be used for the financial evaluation of the cost of a project.

Stating what is required of a code in terms of the functions it should perform and the inputs needed to perform are embedded in the design specification of a program.

Design specification may be described as the functions and capabilities required of a program to be built.

For interactive programs, the design specification will involve creating inputs to be given by the user, this inputs will have rules such that only those which will allow proper functioning of the program is allowed.

Tracking errors and documenting comments are attached program debugging and program readability

Therefore, program specification is useful for describing what is required of a program in terms of it's function or how user's interact with it.

Learn more :https://brainly.com/question/18505492

full detail about computer and its history


Answers

Answer:

The computer as we know it today had its beginning with a 19th century English mathematics professor name Charles Babbage. He designed the Analytical Engine and it was this design that the basic framework of the computers of today are based on. ... It was called the Atanasoff-Berry Computer (ABC).

Explanation:

Edhesive 1.7 Data Types and Variables.
How do I do this correctly

Noun= input (“Enter a noun”)
adjective = input(“Enter an adjective:”)
Print (“the” +noun “is” + adjective)

Answers

Here's how I would do it in python 3+

noun = input("Enter a noun: ")

adjective = input("Enter an adjective: ")

print(f"The {noun} is {adjective}")

I hope this helps!

Eureka! (Part 1) Eureka! is a telephone- and Internetbased concierge service that specializes in obtaining things that are hard to find (e.g., Super Bowl tickets, first-edition books from the 1500s, Fabergé eggs). It currently employs 60 staff members who collectively provide 24-hour coverage (over three shifts). They answer the phones and respond to requests entered on the Eureka! website. Much of their work is spent on the phone and on computers searching on the Internet. The company has just leased a new office building and is about to wire it. What media would you suggest the company install in its office and why?

Answers

Explanation:

bypassing, use more precise words

what's my favorite color

black

red

purple

yellow

orange

Answers

Answer:

.

Explanation:

Which is the faster cpu and why?

Answers

Answer:

Core i7 unlocked

Explanation:

This is known to not only be faster but also more stable.

Answer:

Intel Core i7 Unlocked has more GHz (gigahertz) along with an Octa core.

Explanation:

More gigahertz means your CPU would run all applications at a faster speed and be more efficient. Not only that, an octa core is much more efficient than a quad core. (Octa meaning 8 while Quad being 4).  

What is the quickest way to remove all filters that have been applied to a worksheet?

Answers

Answer:

Click the Filter button in the Sort & Filter group.

Explanation:

Quizlet

Go to the filter option, click sort/filter and unfilter.

Which of the following planets most likely has the coldest surface temperature?
A. Venus
B. Mars
C.
Saturn
D. Mercury

Answers

Answer:

Saturn because it is not that close to the sun

Answer:

Saturn.

I'm dumb i misread the question

Explanation:

Beth wants to add information to her PowerPoint presentation that is hidden from her audience and only she will
see. Which feature should she use?
Notes pane
Title slide
Normal view
Slide Sorter view
Mark this and return

Answers

Answer:

She should use Notes pane

Explanation:

Notes pane is for notes only the creator will see.

Answer:

A. Notes Pane

Explanation:

help !!!!!
Aziz is purchasing a new laptop. The salesperson asks him if he requires any software, as he will get a discount if purchased together. What is that “software” the salesperson is referring to?

• a type of insurance that covers light wear and tear to the laptop for a specified number of years

• a type of protective covering to prevent the laptop from damage in case of falls

• a detailed list of all the hardware connected to the laptop as well as hardware on the laptop

• a set of instructions that enables the laptop to perform certain functions or operations

Answers

I believe it’s D because software is the programs and other operations used by a computer

Answer:

its d

Explanation:

i just did it

"Currency" is a field data type ,it represents Date or time values
True or false tho?

Answers

Answer:

true

Explanation:

Pick a number
You will write a program that will simulate the game where two players try to guess a number and the one who's closest wins.
1. Random secret number from 1 to 10 or any larger range if you want.
2. Two players will guess
3. Determine who was closest.
4. Display the results of the round in a neat and organized fashion.
5. Add some kind of style to your print outs so that your display is nice

Answers

In python 3+:

import random

secret_number = random.randint(1,10)

guess_one = int(input("Enter player one's guess: "))

guess_two = int(input("Enter player two's guess: "))

if abs(guess_one - secret_number) < abs(guess_two - secret_number):

   print(f"The secret number is {secret_number} and player 1 was closest")

elif abs(guess_one - secret_number) > abs(guess_two - secret_number):

   print(f"The secret number is {secret_number} and player 2 was closest")

else:

   print(f"The secret number is {secret_number} and it was a tie")

I hope this helps!

what dose a bios system do?

Answers

BIOS instructs the computer on how to preform basic functions such as booting and keyboard control. It is also used to identify and configure the hardware in a computer
Bios tells computer how to do basic functions
Other Questions
A physical change is easier / more difficult to reverse than a chemical change. North America and Asia are moving toward each other at a rate of about one inch per year. Why are the continents moving so slowly? Multiply. (2/5)(5/4) Enter your answer as a fraction, in simplest form, in the box. Guys what is the adverb of enthusiastic?I need an answer ASAP The general ledger of Pipers Plumbing at January 1, 2018, includes the following account balances: Accounts Debits Credits Cash $ 4,500 Accounts receivable 9,500 Supplies 3,500 Equipment 36,000 Accumulated depreciation $ 8,000 Accounts payable 6,000 Utilities payable 7,000 Deferred revenue 0 Common stock 23,000 Retained earnings 9,500 Totals $ 53,500 $ 53,500 The following is a summary of the transactions for the year:_______. 1. January 24 Provide plumbing services for cash, $18,000, and on account, $63,000. 2. March 13 Collect on accounts receivable, $51,000. 3. May 6 Issue shares of common stock in exchange for $10,000 cash. 4. June 30 Pay salaries for the current year, $32,600. 5. September 15 Pay utilities of $6,200 from 2020 (prior year). 6. November 24 Receive cash in advance from customers, $9,200. 7. December 30 Pay $2,600 cash dividends to stockholders. The following information is available for the adjusting entries. Depreciation for the year on the machinery is $7,200. Plumbing supplies remaining on hand at the end of the year equal $1,000. Of the $9,200 paid in advance by customers, $6,600 of the work has been completed by the end of the year. Accrued utilities at year-end amounted to $6,400. Which excerpt from the story best supports the idea that thenarrator admires the people she interviews the first day on thejob?"I realized the answer was simple Reporter 101: Who?What? Where? When? Why? and How?""I wasn't completely sure what I was supposed to beasking besides how the budget cuts would affecteach school.""It made me think that my new job as a reporter wasgoing to be easy in comparison.""By the time I finished up, I'd gotten a crash course inO interviewing and had received an interesting range ofopinions about the budget cuts." If a student wants to write about the lesson that Greg learns in The Treasure of Lemon Brown that causes him to change, he or she should paraphrase the conversation that Greg has with his father at the beginning of the story. summarize what happens when Greg and Lemon Brown defend themselves against the thugs.paraphrase the conversation that Greg has with Lemon Brown about his treasure. summarize what happens when Greg returns home to his father at the end of the story. Describe the methods of irrigation used by Egyptian farmers along the line river Quadrilateral GHJK has vertices G(2, 3), H(8, 2), J(6, 8), and K(3, 6). It is transformed according to the rule T(4, 5).What are the coordinates of G?(7, 3)(2, 2)(1, 7)(2, 2) please help please solveit Janice is making plans for her company party. She has a budget of $100 taspend. She plans to buy pizza for $12 each, but there will also be a $4delivery charge. How many pizzas can she afford to buy?1. Write the equation: ______2. Janice can buy ___ pizzas for the party. PLEASE HELP! (4x5)3Using the exponential notion and simplify pls PHOTO ADDEDNEED URGENT HELP The differing meanings of "valid inference" and "warranted inference" are closely related to the differing purposes of deductive and inductive arguments the purpose of deductive being to prove; the purpose of inductive to make the conclusion most probable. Look up the words "valid" and "warranted." Each of these words, you will find, has what is known as a lexical definition that is just the dictionary definition of the word. Words also have a certain connotations - meanings that go beyond their lexical definitions; associated ideas and concepts think of terms such a "fur baby" as the name for a pet. Required:Briefly discuss how the lexical definitions and connotations of "valid" and "warranted" can help us understand the differing purposes of deductive and inductive arguments. (1) Thirteen, sixteen, and eighteen: the three ages teenagers look forward to. At thirteen, a kid can finally claim the title teenager. (2) At sixteen, a teenager gains his or her independence. (3) Turning eighteen, a teenager can finally be looked upon as an adult. (4) My golden age was sixteen: my sophomore year of high school and the year everybody starts Drivers Ed.What change needs to be made to sentence 3? 1) change be looked upon to is seen 2) change can finally be to is3) change Turning to At 4 )change Turning to When. I dont understand what this means Are great artistic achievements less admirable if they are paid in dishonest ways, such as through the sale of these special pardons? we need to........... links with those children.1-set2-call3-establish4-communicateplease don't forget to explain There are 18 girls in mr.brimleys class. If 60 percent of the students are girls how many students are in mr.brimleys math class? I really need the answer please!!!!! Explain how an intelligence test could be biased?