Answer:
The definition of the issues is listed throughout the section down.
Explanation:
Stranded cables are somewhat more compact and can be mounted quickly. Strong cables become rigid in design, and they are not versatile for installation. In comparison with solid connectors, amplification is indeed high. Unless the innermost layer including its wire is broken as we attempt to connect the cable, it will not function. So, whenever stripping the cables through the walls, it's indeed important not to rank the jack too profoundly.It would be quick to untwist the cable and then will ensure that perhaps the connection is appropriate for the most widely encountered rj-45 connection whenever the wiring of 0.5 inches becomes coupled up. If we don't keep the right pin colors in order, the relation won't work. Afterward, when another connexon is broken due to many complications, it would be impossible to figure out the contacts unless the pins coloring are not always in sequence.The connection pairs can be cut off through 0.5 inches within about therefore the gap within the connector is narrower and the wire would not be correctly attached if we break the cable further. The link is lost and the cable does not run properly. It is necessary to ensure that perhaps the wires are forced to the end of the platform since the connexon will indeed be broken as well as the connector would not operate unless the wires aren't moved. The wires will fall out of another socket as well.Before even being incorporated into another crimping unit, it is good to carefully check the connection sequence to ensure that perhaps the wires are to the end since it is impossible to verify the sequence until the wires are attached to something like the connector. Unless the connections are not always in alignment, the link will also not be provided and indeed the wire would not operate correctly, even if the link is provided. Such wires can also be presented to use load barriers, and that it's the simplest operation.The Durability Tester has been used to determine the hardness between two stages, whereas the connection efficiency is tested using the qualification tester.
The Internet is considered a WAN. *
True
False
Answer:
true. internet is definitely wan
The statement the Internet is considered a WAN is true.
We are given that;
The statement about WAN
Now,
A WAN, or a wide area network, is a computer network that spans over a large geographic area, such as regions, countries, or even the world.
The Internet is the largest and most well-known example of a WAN, as it connects millions of devices across the globe using various communication protocols and technologies.
A WAN can also be composed of smaller networks, such as local area networks (LANs) or metropolitan area networks (MANs), that communicate with each other.
Therefore, by WAN the answer will be true.
To learn more about WAN visit;
https://brainly.com/question/32733679
#SPJ6
Write an application that accepts a word from a user and converts it to Pig Latin. If a word starts with a consonant, the Pig Latin version removes all consonants from the beginning of the word and places them at the end, followed by ay. For example, cricket becomes icketcray. If a word starts with a vowel, the Pig Latin version is the original word with ay added to the end. For example, apple becomes appleay. If y is the first letter in a word, it is treated as a consonant; otherwise, it is treated as a vowel. For example, young becomes oungyay, but system becomes ystemsay. For this program, assume that the user will enter only a single word consisting of all lowercase letters.
Answer:
Written in Python
word = input("Word: ")
if(word[0]=='a' or word[0]=='e' or word[0]=='i' or word[0] =='o' or word[0]=='u'):
print(word+"ay")
else:
a = word[1:]
print(a+word[0]+"ay")
Explanation:
The program was written in Python and I've added the explanation as an attachment; where I used comments as explanations
The _________ shortcut keys underline words, and not spaces
CTRL+SHIFT+W
Have a nice day :}
18. When you turn off the power to a computer and unplug it at night, it loses the date, and you must reenter it each morning. What is the problem and how do you solve it?
Answer:
If this is a Mac, it's a common problem and there isn't anything to fix it because it's just like that. I reccomend unplugging the computer and NOT signing off. Because of that, that may be why it is the problem for you. I do not know about Windows Computers, but this is some info that applies with all computers.
Explanation:
Answer:
this is what the battery on your motherboard is for. Also as long as you are connected to wifi, then it will sync your computer time with the current timezone you are in.
Explanation:
Which of the following is NOT true about adjustment layers? brainbuffet
Answer the adjustment layers can not be used a lot?
Explanation: i think that was it
Answer:
Initial settings can not be modified, only layer opacity.
Explanation:
Which of the following statements is true of subroutines? Check all that apply.
They can be used in multiple places.
They can be used in one place only.
They save a programmer time since they are reusable.
They can be used only once.
They can contribute to excessive use of a computer’s resources.
They can be used in multiple places.
They save a programmer time since they are reusable.
They can contribute to excessive use of a computer’s resources.
:)
A county collects property taxes on the assessed value of property, which is 60 percent of its actual value. For example, if a house is valued at $158,000.00 its assessed value is $94,800. This is the amount the homeowner pays tax on. If the tax rate is $2.64 for each $100.00 of assessed value, the annual property tax for this house would be $2502.72. Write a program that asks the user for the actual value of a piece of property and the current tax rate for each $100.00 of assessed value. The program should then calculate and display how much annual property tax the homeowner will be charged for his property.
Answer:
actual_value = float(input("Enter the actual value of a piece of property: "))
tax_rate = float(input("Enter the current tax rate for each $100.00 of assessed value: "))
assessed_value = actual_value * 0.6
tax = (assessed_value * tax_rate) / 100
print("The annual property tax is $" + str(tax))
Explanation:
*The code is in Python.
Ask the user to enter the actual value and the tax rate
Calculate the assessed value, multiply the actual value by 0.6
Calculate the tax, multiply the assessed value by the tax rate and divide result by 100
Print the tax
How would improving the nutritional health of an entire community impact the overall physical, emotional, and financial health of that community?
Answer:
The people of the thriving community has a more encouraging life than becoming a town or community of laziness and the fact that people will not help each other. When a community of people know one another they know the at that moment that everyone can get along, but when health comes as a problem, people's attitude toward each other change rapidly in a bad way, then the neighboring families become rivals, and people will not help others when it is most needed, and at that point, life in that area is a internal civil war.
Test Average and Grade
Write a program that asks the user to enter five test scores. The program should display a
letter grade for each score and the average test score. Write the following methods in the
program:
calcAverage:
This method should accept five test scores as arguments and return the
average of the scores.
determineGrade:
This method should accept a test score as an argument and return a
letter grade for the score, based on the following grading scale:
Score Letter Grade
90-100 A
80-89 B
70-79 C
60-69 D
Below 60 F
Expected Output:
Enter·test·grade·for·student·1:55↵ ·
Enter·test·grade·for·student·2:65↵ ·
Enter·test·grade·for·student·3:75↵ ·
Enter·test·grade·for·student·4:85↵ ·
Enter·test·grade·for·student·5:95↵ ·
The·letter·grades·are·as·follows:↵
Student·1:·F↵
Student·2:·D↵
Student·3:·C↵
Student·4:·B↵
Student·5:·A↵
The·average·grade·was:·75.00↵
ISSUES: PLEASE HELP:
I can not get the student's letter grade to display correctly;
I can not get the average to calculate correctly;
Instructions states to write the METHODS in the program.
My output:
Enter test grade for student 1:50
Enter test grade for student 2:60
Enter test grade for student 3:70
Enter test grade for student 4:80
Enter test grade for student 5:90
The letter grades are as follows:
Student 0.0F
Student F
Student F
Student F
Student F
Average:0.0
My Code:
import java.util.Scanner;
public class TestAveGrade{
public static double calcAverage(double userScore1, double userScore2, double userScore3, double userScore4, double userScore5){
double average;
average = (userScore1 +userScore2 +userScore3 +userScore4 +userScore5) /5;
return average;
}
public static String determineGrade(double testScore){
String letterGrade = " ";
if (testScore < 60){
letterGrade = "F";
} else if (testScore <70) {
letterGrade = "D";
}else if (testScore <80) {
letterGrade = "C";
}else if (testScore <90) {
letterGrade = "B";
}else if (testScore <100) {
letterGrade = "A";
}
return letterGrade;
}
public static void main( String [] args) {
Scanner scanner = new Scanner( System.in );
int numberOfScores = 5;
double userScore;
double userScore1 = 0;
double userScore2 = 0;
double userScore3 = 0;
double userScore4 = 0;
double userScore5 = 0;String outputString = "The letter grades are as follows:\n";for(int currentScore = 1; currentScore <= numberOfScores; currentScore++){System.out.print ("Enter test grade for student " + currentScore+":");userScore = scanner.nextDouble();switch (currentScore) {case 1:userScore1 = userScore1;outputString += "Student "+ userScore1 + determineGrade( userScore1) +"\n";break;case 2:userScore2 = userScore2;outputString += "Student "+ determineGrade (userScore2) + "\n";break;case 3:userScore2 = userScore3;outputString += "Student "+ determineGrade (userScore3) + "\n";break;case 4:userScore2 = userScore4;outputString += "Student "+ determineGrade (userScore4) + "\n";break;case 5:userScore2 = userScore5;outputString += "Student "+ determineGrade (userScore5) + "\n";break;default:break;}}System.out.print( outputString + "Average:" + calcAverage (userScore1, userScore2, userScore3, userScore4, userScore5));}}
Answer:
import java.util.Scanner;
public class TestAveGrade
{
public static void main(String[] args) {
Scanner scanner = new Scanner( System.in );
double userScore1, userScore2, userScore3, userScore4, userScore5;
System.out.print ("Enter test grade for student1:");
userScore1 = scanner.nextDouble();
System.out.print ("Enter test grade for student2:");
userScore2 = scanner.nextDouble();
System.out.print ("Enter test grade for student3:");
userScore3 = scanner.nextDouble();
System.out.print ("Enter test grade for student4:");
userScore4 = scanner.nextDouble();
System.out.print ("Enter test grade for student5:");
userScore5 = scanner.nextDouble();
System.out.println("The letter grades are as follows:");
System.out.println("Student-1: " + determineGrade(userScore1));
System.out.println("Student-2: " + determineGrade(userScore2));
System.out.println("Student-3: " + determineGrade(userScore3));
System.out.println("Student-4: " + determineGrade(userScore4));
System.out.println("Student-5: " + determineGrade(userScore5));
System.out.printf("The average grade was: %.2f", calcAverage (userScore1, userScore2, userScore3, userScore4, userScore5));
}
public static double calcAverage(double userScore1, double userScore2, double userScore3, double userScore4, double userScore5){
double average;
average = (userScore1 +userScore2 +userScore3 +userScore4 +userScore5) /5;
return average;
}
public static String determineGrade(double testScore){
String letterGrade = " ";
if (testScore < 60){
letterGrade = "F";
}
else if (testScore <70) {
letterGrade = "D";
}
else if (testScore <80) {
letterGrade = "C";
}
else if (testScore <90) {
letterGrade = "B";
}
else if (testScore <100) {
letterGrade = "A";
}
return letterGrade;
}
}
Explanation:
Hi, I modified your code. Your methods work but you need to update the main.
Ask the user to enter five grades and store the values in different variables
Call the determineGrade method passing each grade as a parameter
Call the calcAverage method passing all the grades as parameter
Create and Provide complete program that includes a comments header with your name, course, section and other program details and does the following: 1) prompt the user to provide a side of square 2) get side from the user and store it into variable 3) based on the side value calculate perimeter of the square 4) calculate area of the square 5) calculate diameter of the square The program should provide the following output: Enter the side of a square: 12 The perimeter is 48.0 The area is 144.0 The length of the diagonal is 16.97056274847714
Answer:
Written using C++
/*Enter Your Details Here*/
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
//1
float side;
cout<<"Enter the side of a square: ";
//2
cin>>side;
//3
float perimeter = 4 * side;
cout<<"The perimeter is "<<perimeter<<endl;
//4
float area = side *side;
cout<<"The area is "<<area<<endl;
//5
float diagonal = sqrt(2 * side * side);
cout<<"The length of the diagonal is "<<diagonal;
return 0;
}
Explanation:
I've added the full source code as an attachment where I used more comments to explain difficult line
When should students practice netiquette in an online course? Check all that apply.
- when sending texts to friends
- when sending emails to classmates
- when collaborating in library study groups
- when participating in online discussion boards
- when collaborating as part of a digital team
Answer:
The answer to this question is given below in the explanation section. However, the correct answer is: student should practice netiquette in an online course when they are participating in online discussion board.
Explanation:
It is important for you as a student to recognize that the online classroom is in fact a classroom, and certain behaviors are expected when you communicate with both your peers and your instructors. These guidelines for online behavior and interaction are known as “netiquette”.
So, the correct option of this question is: students should practice netiquette in an online course when they are participating in an online discussion board. Because the discussion board is opened by the instructor/tutor, he constantly looking for student behavior throughout the discussion. so, students should use netiquette practice during the discussion in the online class.
However, other options are not correct because, in these options, there is not the presence of teacher/instructor. And, also noted that netiquette is practiced in online class by the student.
Answer:
B, D, E
Explanation:
ed2020
How do computers use input and output to get and give the information that they need to solve problems?
Answer:
typing on a keyboard (input) makes letter appear on a screen (output)is removing that
In this exercise we have to be able to explain the difference between output and input used in computers, like this:
So the output allows some information to appear on the screen while the input is a string.
In this way we will define some characteristics of each one as:
Output devices are devices that display data and information processed by the computer, also called output units (input/output). In other words, they allow communication from the computer to the user. Examples: video projector, printer and monitor.The input() function receives as a parameter a string that will be shown as an aid to the user, usually informing him what kind of data the program is expecting to receive.What is the difference between Input and Output?Input, means: Contribute, Input, Insert and etc. In the case of Output, its meaning is: Output, Production, Power, Send.
See more about input or output at brainly.com/question/408477
What is the importance of computer application to statistics
Answer:
First off, I'm not writing your essay. I will give you a guide and you can take it from there. Also, I don't know any context about the question.
Computer applications can handle input and output at a significant rate. Computers were designed to handle mathematical operations and now at today's rate a single 2+2 can spit out a answer in 64 nanoseconds.Write a program that calls fork(). Before calling fork(), have the main process access a variable (e.g., x) and set its value to some-thing (e.g., 100). What value is the variable in the child process? What happens to the variable when both the child and parent change the value of x? Write out the code to your program. Run the program and show your result. What value is the variable in the child process? What happens to the variable when both the child and parent change the value of x?
Answer:
Here is the program:
#include <stdio.h> //to use input output functions
#include <unistd.h> //provides access to the POSIX OS API
int main() { //start of main function
int x; //declare an int type variable x
x = 100; // sets the value of x to 100
int r = fork(); //calls fork() method to create a new process. r is used to store the value returned by fork()
if(r<0){ //if fork() returns -1 this means no child process is created
fprintf(stderr, "Error");} //prints the error message using standard error stream
else if (r == 0) { //if fork returns 0 this means child process is created
printf("This is child process\n"); //prints this message
x = 150; //changes value of x to 150
printf("Value of x in child process: %d\n", x); } //prints the new value of x in child process
else {
printf("This is parent process\n"); //if r>0
x = 200; //changes value of x to 200
printf("Value of x in parent process: %d\n", x); } } //prints the new value of x in parent process
Explanation:
The program is well explained in the comments added to each line of the code. The answers to the rest of the questions are as follows:
What value is the variable in the child process?
The variable x is set to 150 in child process. So the printf() statement displays 150 on the screen.
What happens to the variable when both the child and parent change the value of x?
fork() creates a copy of parent process. The child and parent processes have their own private address space. Therefore none of the both processes cannot interfere in each other's memory. The both maintain their own copy of variables. So, when parent process prints the value 200 and child process prints the value 150.
In order to see which is the final value of x, lets write a statement outside all of the if else statements:
printf("Final value of x: %d\n", x);
This line is displayed after the value of parent class i.e. 200 is printed on the screen and it shows:
Final value of x: 200
Note this is the value of x in parent process
However the same line displayed after the value of child class i.e. 150 is printed on the screen and it shows:
Final value of x: 150
The screenshot of the program along with the output is attached.
In this exercise we have to use the knowledge of computational language in C code to describe a code, like this:
The code can be found in the attached image.
To make it easier the code can be found below as:
#include <stdio.h>
#include <unistd.h>
int main() {
int x;
x = 100;
int r = fork();
if(r<0){
fprintf(stderr, "Error");}
else if (r == 0) {
printf("This is child process\n");
x = 150;
printf("Value of x in child process: %d\n", x); }
else {
printf("This is parent process\n");
x = 200;
printf("Value of x in parent process: %d\n", x); } }
See more about C code at brainly.com/question/25870717
Danielle, Edward, and Francis are three salespeople at Holiday Homes. Write an application named HomeSales that prompts the user for a salesperson initial (D, E, or F ). Either uppercase or lowercase initials are valid. Issue an error message for any invalid initials entered. For any salesperson name initial entered, further prompt a sale amount sold by the salesperson. Afterward, display the salesperson’s name and the sale amount for the salesperson.
Answer:
import java.util.Scanner;
public class HomeSales
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String name = "";
double sale = 0.0;
System.out.print("Enter a salesperson's initial (D, E, or F ) ");
char initial = input.next().charAt(0);
initial = Character.toUpperCase(initial);
if(initial == 'D')
name = "Danielle";
else if(initial == 'E')
name = "Edward";
else if(initial == 'F')
name = "Francis";
else
System.out.println("Invalid initials entered!");
if(!name.equals("")){
System.out.print("Enter sale amount ");
sale = input.nextDouble();
System.out.println(name + " " + sale);
}
}
}
Explanation:
*The code is in Java.
Initialize the name and sale
Ask the user to enter the initial
Convert initial to uppercase
Check the initial using if else statement and depending on the value, set the name. If a valid initial is entered, print an error.
If the name is not empty (This implies that a valid initial was entered), ask the user to enter the sale amount and print the name and sale amount
What feature adjusts the top and bottom margins so that the text is centered vertically on the printed page?
Question 6 options:
Vertical centering
Vertical justifying
Vertical adjusting
Dual centering
Answer:
Vertical justifying
Explanation:
Assume you have a sorting algorithm that you can use as a black box (that means it is already written and you just call it and use it). We use the sorting algorithm and sort the input list. Now consider the sorted list and write an algorithm to count the number of duplicates again. Analyze the time complexity of your algorithm in the worstcase (ignore the time complexity of sorting). Could you improve the worst-case time complexity of your algorithm compared to the previous question?Why? Explain
Answer:
Follows are the solution to this question:
Explanation:
In the previous algorithm has also been fine yet un optimal and also gives O(n^2) computation time, that is is very powerful. It is a proposed algorithm, that has been arriving because its method has also been defined, its sorting provides the O( nlogn), which is much better than the last time complexity.
When did I consider repeat figures, it is another aspect to note at the same figures arise as figures are ordered, for instance, the number is 1, 2, 1, 3, 2, 1, 3. It becomes such as these number once sorted 1 , 1 , 1, 2 , 2 , 3 , 3.
The smaller number 1, that's also 3 times combined in the second-largest amount, which is 2 times, but instead number 3, that's 2 times together consequently, with one pass in series, they can conveniently check the amount of duplicate.
It is a particular characteristic that appears 2 or more times, so it gets the same increases and amount for multiple copies when it sorted, and search for a specific transaction if it is equal with the original weeks. If there is indeed a problem we have an amount more than 2 times for the same amount we need additional iterations.
Therefore, the second 1 method fits it's very first 1 and its increase in multiple copies, however, the third 1 is the same for the second 1, so the amount of double for step 1 was already increased again so the same number also has an element following. To remove this problem, a hashmap keeps track as a number, which crossed 1 time must be initialized the algorithm and doesn't search for amount again.
The algorithm functions as follows:
1.initialize a hashmap which defaults to 0.
2.Now sorted array with the second position element.
3.Check if the element hashmap value is 0 as well as the previous variable has the same value.
4. Increase the number of multiple copies and fill out hazmap element to 1 if both conditions and AND conditions become valid.
5. if the element and move to the next item if the state of AND is wrong.
6. go to 3 and take the same steps to the end of the array.
which term means the push that makes electrons move in a wire?
A. adapter
B. digital signal
C. voltage
D. current
Answer:
C. Voltage
Explanation:
Answer:
Other person is correct it is voltage
Explanation:
Which of the followingdemonstrates active listening while receiving constructive criticism well?
O "I don't think what you are saying is helpful to me."
O "Okay. Thank wu. So where do you want to go for lunch?"
O "You mentioned that the quality of my software code could be better. You need to look at what Joe is writing. My
code is far superior to his."
O "You mentioned that the quality of my software code could be better. Can you tell me more about this and what I should look for “
Answer:
its D
Explanation:
Answer:
d
Explanation:
d
The term____relates to all things that we see.
In a word processing program, under which tab or menu option can you adjust the picture brightness? A. Insert B. Format C. View D. Page Layout
Answer:
B. Format
Explanation:
You must have selected a picture in order the tab Format to be available. You should click the picture that you want to change the brightness for and u under Picture Tools, on the Format tab, in the Adjust group, click Corrections. And the correct option is the Format tab.
Why do you think there is a difference in results between search engines ?
Answer:
Explanation:
Search Engine Optimization (SEO) was created. These businesses help websites improve their ranking by getting a website linked to other sites, using better keywords to describe the site and use in the site’s content, leveraging social media promotions, reWhat this means is that even the “unpaid for” search results you see probably got there because companies or organizations spent a great deal of money to get their website listed at the top. designing websites and more.
The macro command is available on the ___ tab
Home
Insert
View
Design
Answer:
The marco command is available on the VIEW tab.
Your welcome!!!
Television broadcasts were originally delivered by using which technology
Answer:
Wireless technology.
Explanation:
In earlier years, the broadcasting of information or any video or audio type was done "over-the-air". This means that sharing or the distribution of any content was done "wireless", through the use of transmitters that are wireless or requires no physical connecting wires.
Wireless technological form of broadcasting became the original form of distributing media, be it entertainment, news or information, etc. This 'over-the-air' broadcasting was then replaced by the cabled-wires transmission later on.
The technology through which Television broadcasts were originally delivered was through:
Wireless technology.
According to the given question, we are asked to state the technology through which Television broadcasts were originally delivered
As a result of this, we can see that in the earlier years, there was the use of wireless technology to relay the transmissions of information through radio waves or short waves and did not require any physical connection of wires.
'Read more about Wireless technology here:
https://brainly.com/question/25633298
Which of these devices must be installed in every individual computing device on the
network? Choose the answer.
network adapter
router
switch
repeater
Answer:
network adapter
Explanation:
took the test
A procedure for solving a problem in terms of the actions to be executed and the order in which to
execute those actions is known as a(n).
Answer:
A procedure for solving a problem in terms of the actions to be executed and the order in which to execute those actions is known as a(n).
A user can easily moved to the end of document by pressing what key combination?
Ctrl+Down
Ctrl+end
Ctrl+E
Alr+end
Which element is located on the top left of the Word screen? Quick Access toolbar
Which key combination will move the user to the beginning of the document? Ctrl+Home
A user can easily move to the end of a document by pressing the _____ key combination. Ctrl+End
Jemima is reviewing her history report and notices that her headings are not formatted the same throughout the
report. She wants to modify the style of her headings
What should she do first?
What should she do next?
Answer:
-Select one of the headings.
-Open the Styles dialog box.
Explanation:
edge 2020
Answer:
Man above me is right listen to him
Explanation:
Where do you go to create a workbook?
Answer:
The explaination of this question is given below in the explanation section
Explanation:
The following steps are used to create a workbook.
1- Go to start menu and search about EXCEL (application software) and then click on it to open.
If you already opened a EXCEL's workbook, and you want to create a new workbook, then you follow the following steps:
Click the File tab. Click New. Under Available Templates, double-click Blank Workbook. Keyboard shortcut To quickly create a new, blank workbook, you can also press CTRL+N.A new workbook will be created.
Write a function with two parameters, prefix (a string, using the string class from ) and levels (an unsigned integer). The function prints the string prefix followed by "section numbers" of the form 1.1., 1.2., 1.3., and so on. The levels argument determines how many levels the section numbers have. For example, if levels is 2, then the section numbers have the form x.y. If levels is 3, then the section numbers have the form x.y.z. The digits permitted in each level are always '1' through '9'. As an example, if prefix is the string "BOX:" and levels is 2, then the function would start by printing:
Answer:
Here is the program:
#include <iostream> //to use input output functions
#include <string> // to use functions to manipulate strings
using namespace std; //to identify objects cin cout
void function(string prefix, unsigned int levels){ // function that takes two parameters, a string, using the string class and levels an unsigned integer
if (levels == 0) { //if number of levels is equal to 0
cout << prefix << endl; //displays the value of prefix
return; }
for (int i = 1; i <=9 ; i++){ //iterates 1 through 9 times
string sections = (levels == 1 ? "" : "."); //if the number of levels is equal to 1 then empty space in sections variable otherwise stores a dot
string output = prefix + std::to_string(i) + sections; // displays the string prefix followed by the section numbers. Here to_string is used to convert integer to string
function(output, levels - 1); } } //calls function by passing the resultant string and levels-1 recursively to print the string prefix followed by section numbers
int main() { // start of main function
int level = 2; //determines the number of levels
function("BOX", level); } //calls function by passing the string prefix and level value
Explanation:
The program has a function named function() that takes two parameters, prefix (a string, using the string class from ) and levels (an unsigned integer). The function prints the string prefix followed by "section numbers" of the form 1.1., 1.2., 1.3., and so on. The levels argument determines how many levels the section numbers have. If the value of levels is 0 means there is 0 level then the value of prefix is printed. The for loop iterates '1' through '9' times for number of digits in each level. If the number of levels is 1 then space is printed otherwise a dot is printed. The function() calls itself recursively to print the prefix string followed by section numbers.
Let us suppose that prefix = "BOX" and level = 1
If level = 1 then the loop for (int i = 1; i <=9 ; i++) works as follows:
At first iteration:
i = 1
i <=9 is true because value of i is 1
string sections = (levels == 1 ? "" : "."); this statement checks if the levels is equal to 1. It is true so empty space is stored in sections variable so,
sections = ""
Next, string output = prefix + std::to_string(i) + sections; statement has prefix i.e BOX plus value of i which is 1 and this int value is converted to string by to_string() method plus sections has an empty space. So this statement becomes
string output = BOX + 1
So this concatenates BOX with 1 hence output becomes:
output = BOX1
At second iteration:
i = 2
i <=9 is true because value of i is 2
string sections = (levels == 1 ? "" : "."); is true so
sections = ""
Next, string output = prefix + std::to_string(i) + sections; statement becomes
string output = BOX + 2
So this concatenates BOX with 1 hence output becomes:
output = BOX2
At third iteration:
i = 3
i <=9 is true because value of i is 3
string sections = (levels == 1 ? "" : "."); is true so
sections = ""
Next, string output = prefix + std::to_string(i) + sections; statement becomes
string output = BOX + 3
So this concatenates BOX with 1 hence output becomes:
output = BOX3
Now at each iteration the prefix string BOX is concatenated and printed along with the value of i. So at last iteration:
At last iteration:
i = 9
i ==9 is true because value of i is 9
string sections = (levels == 1 ? "" : "."); is true so
sections = ""
Next, string output = prefix + std::to_string(i) + sections; statement becomes
string output = BOX + 9
So this concatenates BOX with 1 hence output becomes:
output = BOX9
After this the loop breaks at i = 10 because the condition i<=9 becomes false. So the output of the entire program is:
BOX1 BOX2 BOX3 BOX4 BOX5 BOX6 BOX7 BOX8 BOX9
The program along with the output is attached.