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
goldenfox [79]
3 years ago
11

Write a method called makeLine. The method receives an int parameter that is guaranteed not to be negative and a character. The

method returns a String whose length equals the parameter and contains no characters other than the character passed. Thus, if the makeLine(5,':') will return ::::: (5 colons). The method must not use a loop of any kind (for, while, do-while) nor use any String methods other than concatenation. Instead, it gets the job done by examining its parameter, and if zero returns an empty string otherwise returns the concatenation of the specified character with the string returned by an appropriately formulated recursive call to itself.
Computers and Technology
1 answer:
Cloud [144]3 years ago
5 0

Answer:

public static String makeLine (int n, char c) {

   if (n ==0)

return "";

   else

       return (c + makeLine(n-1, c));

}

Explanation:

Create a method called makeLine that takes two parameters, int n and char c

If n is equal to 0, return an empty string

Otherwise, call the method with parameter n decreased by 1 after each call. Also, concatenate the given character after each call.

For example, for makeLine(3, '#'):

First round -> # + makeLine(2, '#')

Second round -> ## + makeLine(1, '#')

Third round -> ### + makeLine(0, '#') and stops because n is equal to 0 now. It will return "###".

You might be interested in
Ld' is the instruction with the longest latency on the CPU from Section 4.4 (in RISC-V text). If we modified ld and sd so that t
antiseptic1488 [7]

Answer:

See explaination

Explanation:

a)

The primary factors that influence the program's speed on a new CPU are given as:-

CPU Clock speed where the speed of the process instructions is being measured.

Multi-core which is when the transistors work faster than respective CPU.

Cache which helps to note that the transition of data is smooth and fast.

b)

So, there are two CPUs suppose the old one as 'A' and the modified one as 'B'.

'A' has following features---

It takes more time to execute program as it has more clock cycle time or we can say it has low clocking rate or low speed in terms of MHz or GHz. Clock rate is the inverse of Clock Cycle Time. When you will increase the clocking rate of CPU, it will get faster and then Clock Cycle Time will get reduced.

It has less instructions provided.

'B' has following features----

It takes less time to execute program as it has less clock cycle time or we can say it has high clocking rate or high speed in terms of MHz or GHz.

It has more instructions provided.

The performance of CPU depends upon 2 factors:

The number and types of instructions that are executed by the CPU

How fast the CPU can execute those instructions?

So, overall CPU B is better as it has less execution time than CPU A but the performance will always depend upon the number and type of instructions executed by the CPU so it may vary.

Please refer to attachment for instructions and formulas.

8 0
3 years ago
Define a lambda function that accepts one argument (a list of strings) and returns a list of only the words that start with an '
Grace [21]

Answer:

  1. def Lambda(strList):
  2.    return list(filter(lambda s: (s.startswith("e")), strList))
  3. print(Lambda(["meaning", "cart", "engine", "egg"]))

Explanation:

The solution code is written in Python 3.

Lambda function is an anonymous function. It is a function without any name and it is started with keyword lambda. To write a lambda function to filter the string started with an 'e', we can write a lambda expression, s.startswith("e") that work on one input strList. If any word from strList started with letter "e", the word will be added into a list generated by filter function. At the end, the Lambda function will return the list of strings as output.

When we test the Lambda function using the sample string list (Line 4), we shall get ['engine', 'egg'] printed to terminal.

8 0
3 years ago
A. True
Artist 52 [7]

This is true. In some languages, constructors can be made private to restrict the ways in which objects can be created.

4 0
3 years ago
Eq-20 why is the height of a vhf radio antenna important
masya89 [10]
Reasons why the height of a VHF radio antenna is important is because VHF radios work by the line of sight principle.
Line of sight
its a line from observers eye to a distant point.its a line between two points specifically the straight path between a transmitting antenna (as for radio or television signals) and receiving antenna when unobstructed by the horizon.
7 0
3 years ago
Read 2 more answers
Sales Prediction A company has determined that its annual profit is typically 23 percent of total sales. Design a program that a
Brut [27]

Answer:

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

Explanation:

 This question is about calculating the profit from the annual projected sales of a company.      

You can calculate the profit by using the following formula:

profit = annual projected sales x annual profit.

So, the code (solution) is given below, however, it is noted that this program is written in c++ language.

#include <iostream>

using namespace std;

int main()

{

   long double annualProfitPercentage=0.23;// annual profit 23%.

   long double projectedSales,profit;/* declare variable to store the annual projected sales and profit */

   cout<<"*********Sales Prediction*********\n"; //output heading

   cout<<"\nEnter the project amount of total sales: ";// take input from user

   cin>>projectedSales;// store input into variable projectedSales

   

   profit = projectedSales *  annualProfitPercentage;//calculate profit

   cout<<"Profit is: "<<profit;//print result

   

   

   

   return 0;

}

3 0
2 years ago
Other questions:
  • Which of the following describes an acceptable print resolution?
    7·1 answer
  • What is an extrinsic value? A. something that is valuable in and of itself B. something that is valuable because it leads to ano
    12·1 answer
  • What action makes RAM on your computer disappear?
    12·2 answers
  • What nondestructive testing method requires little or no part preparation, is used to detect surface or near-surface defects in
    7·1 answer
  • Files with what two file extensions are commonly known as tarballs??
    8·1 answer
  • Differences between electromechanical era and electronic era in point.<br>PLZ HELP​
    6·1 answer
  • Next, Leah wants to add a content slide that allows her to insert a table.
    8·2 answers
  • your friend's parent's are worried about going over their budget for the month. Which expense would you suggest is NOT a need?
    11·1 answer
  • 5. What skill is unique to reading online?
    14·1 answer
  • Examine the following output:
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!