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]
1 year 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]1 year 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 BCD code is being transmitted to a remote receiver. The bits are A3, A2, A1, and A0, with A3as the MSB. The receiver circuitry
NARA [144]
<span>BCD only goes from digit 0 (0000) to digit 9 (1001), because for 10 you need two digits, so all you've got to do is make a function that produces high for numbers from 10 (1010) to 15 (1111) as follows:
A3 A2 A1 A0   F
 0    0    0    0    0
 0    0    0    1    0
 0    0    1    0    0
 ...........................
 1    0    0    0    0
 1    0    1    0    1
 1    0    1    1    1
 1    1    0    0    1
 1    1    0    1    1
 1    1    1    0    1
 1    1    1    1    1
 
Then simplify the function: F = A3*A2 + A3*A1 Finally just draw or connect the circuit using NAND</span>
3 0
1 year ago
An author is preparing to send their book to a publisher as an email attachment. The file on their computer is 1000 bytes. When
Yakvenalex [24]

Answer:

See explanation

Explanation:

My explanation to the author is that:

The reduction in size of the attachment doesn't mean that some parts of the book (i.e. the attachment) has been deleted.

I'll also made him understand that the book will retain its original size and contents after downloading by the recipient of the mail.

6 0
2 years ago
11.19 LAB: Max magnitude Write a function max_magnitude() with two integer input parameters that returns the largest magnitude v
AlekseyPX

Answer:

# the user is prompt to enter first value

user_val1 = int(input("Enter first value: "))

# the user is prompt to enter second value

user_val2 = int(input("Enter second value: "))

# max_magnitude function is defined

# it takes two parameters

def max_magnitude(user_val1, user_val2):

# if statement to compare the values

# it compare the absolute value of each

if(abs(user_val2) > abs(user_val1)):

return user_val2

elif (abs(user_val1) > abs(user_val2)):

return user_val1

# max_magnitude is called with the

# inputted value as parameter

print(max_magnitude(user_val1, user_val2))

Explanation:

The code is written in Python and well commented. A sample image of program output is attached.

3 0
1 year ago
Create a class named BaseballGame that contains data fields for two team names and scores for each team in each of nine innings.
m_a_m_a [10]

Answer:

Check the explanation

Explanation:

BaseballGame:

public class BaseballGame {

  protected String[] names = new String[2];

  protected int[][] scores;

  protected int innings;

  public BaseballGame() {

      innings = 9;

      scores = new int[2][9];

      for(int i = 0; i < 9; i++)

          scores[1][i] = scores[0][i] = -1;

  }

 

  public String getName(int team) {

      return names[team];

  }

  public void setNames(int team, String name) {

      names[team] = name;

  }

 

  public int getScore(int team, int inning) throws Exception {

      if(team < 0 || team >= 2)

          throw new Exception("Team is ut of bounds.");

      if(inning < 0 || inning >= innings)

          throw new Exception("Inning is ut of bounds.");

     

      return scores[team][inning];

  }

  public void setScores(int team, int inning, int score) throws Exception {

      if(team < 0 || team >= 2)

          throw new Exception("Team is ut of bounds.");

      if(inning < 0 || inning >= innings)

          throw new Exception("Inning is ut of bounds.");

      if(score < 0)

          throw new Exception("Score is ut of bounds.");

      for(int i = 0; i < inning; i++)

          if(scores[team][i] == -1)

              throw new Exception("Previous scores are not set.");

     

      scores[team][inning] = score;

  }

 

}

HighSchoolBaseballGame:

public class HighSchoolBaseballGame extends BaseballGame {

  public HighSchoolBaseballGame() {

      innings = 7;

      scores = new int[2][7];

      for(int i = 0; i < 7; i++)

          scores[1][i] = scores[0][i] = -1;

  }

}

LittleLeagueBaseballGame:

public class LittleLeagueBaseballGame extends BaseballGame {

  public LittleLeagueBaseballGame() {

      innings = 6;

      scores = new int[2][6];

      for(int i = 0; i < 6; i++)

          scores[1][i] = scores[0][i] = -1;

  }

}

6 0
1 year ago
Initialize the list short_names with strings 'Gus', 'Bob', and 'Zoe'. Sample output for the given program:
ohaa [14]

Answer:

Following are the correct code to this question:

short_names=['Gus','Bob','Zoe']#defining a list short_names that holds string value

print (short_names[0])#print list first element value

print (short_names[1])#print list second element value

print (short_names[2])#print list third element value

Output:

Gus

Bob

Zoe

Explanation:

  • In the above python program code, a list "short_names" list is declared, that holds three variable that is "Gus, Bob, and Zoe".
  • In the next step, the print method is used that prints list element value.
  • In this program, we use the list, which is similar to an array, and both elements index value starting from the 0, that's why in this code we print "0,1, and 2" element value.
7 0
1 year ago
Other questions:
  • What helps companies and organizations to target masses of people, provide 24/7 services, and deliver better marketing in a chea
    13·2 answers
  • In three to four sentences, describe why CEOs (the chief executive officers, that is, the leaders of large companies) make very
    9·1 answer
  • What is a cursor?
    6·2 answers
  • James is an employee at the packaging unit of a chocolate factory that has come up with a new concept of packaging and marketing
    11·2 answers
  • The following parts were ordered by someone building a personal computer:
    12·1 answer
  • A user complains that his computer automatically reboots after a short period of time. Which of the following computer component
    10·2 answers
  • Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
    12·1 answer
  • Assume you have a project with seven activities labeled A-G (following). Derive the earliest completion time (or early finish-EF
    15·1 answer
  • Describe copyright statute, disclaimers, and filing procedures.
    5·1 answer
  • A school has 100 lockers and 100 students. All lockers are closed on the first day of school. As the students enter, the first s
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!