answer.
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
Alex787 [66]
2 years ago
7

1. Assign to maxSum the max of (numA, numB) PLUS the max of (numY, numZ). Use just one statement. Hint: Call FindMax() twice in

an expression.
Sample program:
double FindMax(double num1, double num2) {
double maxVal = 0.0;
if (num1 > num2) { // if num1 is greater than num2,
maxVal = num1; // then num1 is the maxVal.
} else { // Otherwise,
maxVal = num2; // num2 is the maxVal.
}
return maxVal;
}

int main() {
double numA = 5.0;
double numB = 10.0;
double numY = 3.0;
double numZ = 7.0;
double maxSum = 0.0;

cout << "maxSum is: " << maxSum << endl;
return 0;
}
2. Define a function PrintFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. Ex: PrintFeetInchShort(5, 8) prints:
5' 8"
Hint: Use \" to print a double quote.
Sample program:
#include
using namespace std;

int main() {
PrintFeetInchShort(5, 8);
cout << endl;
return 0;
}
3. Complete the PrintTicTacToe function with char parameters horizChar and vertChar that prints a tic-tac-toe board with the characters as follows. End with newline. Ex: PrintTicTacToe('~', '!') prints:
x!x!x
~~~~~
x!x!x
~~~~~
x!x!x
Sample program:
#include
using namespace std;
void PrintTicTacToe(char horizChar, char vertChar) {

return;
}
int main() {
PrintTicTacToe('~', '!');
return 0;
}
4. Complete the PrintShape() function to print the following shape. End with newline.
Example output:
***
***
***
Sample program:
#include
using namespace std;
void PrintShape() {

return;
}
int main() {
PrintShape();
return 0;
}
5. Complete the function definition to print five asterisks ***** when called once (do NOT print a newline). Output for sample program:
**********
Sample program:
#include
using namespace std;
void PrintPattern() {

}
int main() {
PrintPattern();
PrintPattern();
cout << endl;
return 0;
}

Computers and Technology
1 answer:
Roman55 [17]2 years ago
3 0

Answer:

1)

maxSum = FindMax(numA, numB) + FindMax(numY, numZ);

2)

void PrintFeetInchShort(int numFeet , int numInches){

cout<<numFeet<<"'"<<numInches<<"\""; }

3)

void PrintTicTacToe(char horizChar, char vertChar){

   for(int r=1;r<=3;r++)    {

       for(int c=1;c<=3;c++)        {

           cout<<"x";

           if(c<=2)            {

               cout<<vertChar;     }        }

       cout<<endl;

       if(r != 3)  {

           for(int c = 1; c<=5; c++)            {

              cout<<horizChar;            }

           cout<<endl;        }    } }

4)

void PrintShape(){

for(int r=1;r<=3;r++){

for(int c=1;c<=3;c++){

cout<<"*"; }

cout<<endl;} }

5)

void PrintPattern(){

for(int r=1;r<=5;r++){

   cout<<"*"; } }

Explanation:

1.

In the statement, maxSum is a double type variable which is assigned the maximum of the two variables numA numB PLUS the maximum of the two variables numY numZ using which are found by calling the FindMax function. The FindMax() method is called twice in this statement one time to find the maximum of numA and numB and one time to find the maximum of numY numZ. When the FindMax() method is called by passing numA and numB as parameters to this method, then method finds if the value of numA is greater than that of numB or vice versa. When the FindMax() method is called by passing numY and numZ as parameters to this method, then method finds if the value of numY is greater than that of numZ or vice versa. The PLUS sign between the two method calls means that the resultant values returned by the FindMax() for both the calls are added and the result of addition is assigned to maxSum

2.

The above function takes two integer variables numFeet and numInches as its parameters. The cout statement is used to print the value of numFeet with a single quote at the end of that value and  print the value of numInches with double quotes at the end of that value. Here \ backslash is used to use the double quotes. Backslash is used in order to include special characters in a string. In order to add double quotes with a string or a value, backslash is compulsory.

3.

The function PrintTicTacToe has two character type (char) parameters  horizChar and vertChar.

The function has two loops; outer loop and an inner loop. The outer loop is used to iterate through the rows and inner loop is used to iterate through the columns. The inner loop iterates and prints a row of the character "x" followed by  vertChar which contains a character ! . This means at each iteration x! is printed and it stops at the third "x" as the loop variable c iterates until the value of c remains less than or equal to 3. Notice that the last "x" in each row is not followed by a "!" because of if(c<=2) condition which prints ! only till the second column which means cout<<vertChar; statement only executes until the value of c remains less than or equal to 2. When the value exceeds 2 then the next if statement  if(r != 3) executes which checks if the value of r is not equal to 3.  If this condition is true then the loop inside this 2nd if statement executes which prints value of horizChar at each iteration and horizChar contains "~". c<=5; means that the loop will print "~" 5 times. After the first row of x!x!x and ~~~~~ are printed the outer loop executes for the next iteration and outer loop variable r is incremented to one to print the second row of x!x!x

~~~~~ using inner loop and two if conditions. This outer loop body executes 3 times.

4.

The function has two loops an inner and outer loop. Outer loop is used for rows and inner for columns. At each iteration of inner loop an asterisk is printed and the inner loop runs for 3 times which means three asterisks will print ***. The outer loop executes for 3 times which means total three rows of three *** asterisks are displayed each ***  asterisks are printed with a new line using cout<<endl; statement.

5.

The function uses a loop for(int r=1;r<=5;r++) to print 5 asterisks ***** without printing a new line. The function PrintPattern() is called twice which means the pattern of 5 asterisks ***** is printed twice as: ********** without printing a new line between them.

You might be interested in
A city government is attempting to reduce the digital divide between groups with differing access to computing and the Internet.
sergeinik [125]

Answer:

C

Explanation:

Putting all government forms on the city web site is the least activity likely to be effective in the purpose of reducing digital divide.

Holding basic computer classes at the community centers will very much help to reduce the digital divide.

Providing free wireless internet connections at locations in low-income neighborhood will also reduce the gap of digital divide

Requiring that every city school has computers that meet a minimum hardware and software will made computing resources available to users thereby reducing digital divide.

5 0
1 year ago
#Write a function called string_finder. string_finder should #take two parameters: a target string and a search string. #The fun
adoni [48]

Answer:

I am writing a Python program:

def string_finder(target,search): #function that takes two parameters i.e. target string and a search string

   position=(target.find(search))# returns lowest index of search if it is found in target string

   if position==0: # if value of position is 0 means lowers index

       return "Beginning" #the search string in the beginning of target string

   elif position== len(target) - len(search): #if position is equal to the difference between lengths of the target and search strings

       return "End" # returns end

   elif position > 0 and position < len(target) -1: #if value of position is greater than 0 and it is less than length of target -1

       return "Middle" #returns middle        

   else: #if none of above conditions is true return not found

       return "not found"

#you can add an elif condition instead of else for not found condition as:

#elif position==-1    

#returns "not found"

#tests the data for the following cases      

print(string_finder("Georgia Tech", "Georgia"))

print(string_finder("Georgia Tech", "gia"))

print(string_finder("Georgia Tech", "Tech"))

print(string_finder("Georgia Tech", "Idaho"))

Explanation:

The program can also be written in by using string methods.

def string_finder(target,search):  #method definition that takes target string and string to be searched

       if target.startswith(search):  #startswith() method scans the target string and checks if the (substring) search is present at the start of target string

           return "Beginning"  #if above condition it true return Beginning

       elif target.endswith(search):  #endswith() method scans the target string and checks if the (substring) search is present at the end of target string

           return "End" #if above elif condition it true return End

       elif target.find(search) != -1:  #find method returns -1 if the search string is not in target string so if find method does not return -1 then it means that the search string is within the target string and two above conditions evaluated to false so search string must be in the middle of target string

           return "Middle"  #if above elif condition it true return End

       else:  #if none of the above conditions is true then returns Not Found

           return "Not Found"

6 0
1 year ago
To gain experience of using and combing different sorting algorithms: election sort, insertion sort, merge sort, and quick sort.
ch4aika [34]

Answer:

Motivation? The search problem.

Sorting algorithms: insertion sort, shellsort, heapsort, mergesort, quicksort, bubblesort

At the very least, "general purpose" sorting algorithms require O(n log n) comparisons

Explanation:

3 0
2 years ago
A signal travels from point A to point B. At point A, the signal power is 100 W. At point B, the power is 90 W. What is the atte
11Alexandr11 [23.1K]

Answer:

Attenuation = 0.458\ db

Explanation:

Given

Power at point A = 100W

Power at point B = 90W

Required

Determine the attenuation in decibels

Attenuation is calculated using the following formula

Attenuation = 10Log_{10}\frac{P_s}{P_d}

Where P_s = Power\ Input and P_d  = Power\ output

P_s = 100W

P_d = 90W

Substitute these values in the given formula

Attenuation = 10Log_{10}\frac{P_s}{P_d}

Attenuation = 10Log_{10}\frac{100}{90}

Attenuation = 10 * 0.04575749056

Attenuation = 0.4575749056

Attenuation = 0.458\ db <em>(Approximated)</em>

7 0
2 years ago
Adrian has decided to subscribe to a new internet service. He wants a high-speed connection so he can stream video content smoot
vichka [17]
I believe the answer is A but then again it could be c because if u mess the cable cord up the internet will stop working 
7 0
2 years ago
Read 2 more answers
Other questions:
  • PLEASE HELP!! WILL GIVE BRAINLIEST!!
    15·2 answers
  • The ________ method is based on simple arithmetic. The process involves dividing the bits of a frame into equal segments, adding
    11·1 answer
  • A ____ resembles a circle of computers that communicate with each other.
    14·1 answer
  • Identify the normalized form of the mantissa in 111.01.
    14·1 answer
  • Initialize a list. ACTIVITY Initialize the list short.names with strings 'Gus', Bob, and 'Ann'. Sample output for the given prog
    9·1 answer
  • You have configured your firewall to authenticate a group of 100 users who are in your company. You set up the database of users
    14·1 answer
  • Select the correct answer. Andy wants to become a multimedia producer. Which degree can help him achieve this goal? A. bachelor’
    5·1 answer
  • Write code that determines the number of full days represented by the number of hours stored in the variable hours and stores th
    15·1 answer
  • Calvin is an aspiring graphic designer. He wants to achieve Adobe Certified Expert certification in software that will be helpfu
    9·1 answer
  • Acceleration is the rate at which an object changes its velocity. It is typically represented by symbol a and measured in m/s2 (
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!