Need these questions answered…

Need these questions answered…

Question 1-3 should be submitted in a single Microsoft Word file. Be sure to clearly label your solutions. Questions 4-6 should be submitted as C++programs/files.

Your week 8 final exam rubric is included in the assignment details page, or you may also click on the “See Rubric” button at the top of your dropbox page to view how the instructor will grade your assignment. Click on the “Assignments” link in the left sidebar to access your weekly dropboxes.

After you have completed your assignment, title your file(s) with: LastNameCourseIDFinalExamQ# (ex. SmithGU100FinalExamQ1), attach them to this dropbox, and press Submit.

*Please add the question number to the end of your file; for example question 1 will be Q1, question 4 will be Q4, etc.

Question 1


Consider the following program:

#include
#include
#include

using namespace std;

int main()

{
int num1;
int num2;

cout << fixed << showpoint << setprecision(2);

cout << “Enter two integers: “;
cin >> num1 >> num2; cout << endl;

if (num1 != 0 && num2 != 0)
cout << sqrt(abs(num1 + num2) + 0.5) << endl;
else if (num1 != 0)
cout << floor(num1 + 0.5) << endl;
else if (num2 != 0)
cout << ceil(num2 + 0.5) << endl;
else
cout << 0 << endl;

return 0;
}

a. What is the output if the input is -23 8?
b. What is the output if the input is 12 32?
c. What is the output if the input is 15 0?
d. What is the output if the input is 0 -36?
e. What is the output if the input is 0 0?

Question 2

Write the definition of a function that takes as input the three numbers. The function returns true if the first number to the power of the second number equals the third number; otherwise, it returns false. (Assume that the three numbers are of type double).

Question 3

Write C++ statements that do the following:

  1. Define an enum type, birdType, with the values PEACOCK, SPARROW, CANARY, PARROT, PENGUIN, OSTRICH, EAGLE, CARDINAL, and HUMMINGBIRD.
  2. Declare a variable bird of the type birdType.
  3. Assign CANARY to the variable bird.
  4. Advance bird to the next value in the list.
  5. Decrement bird to the previous value in the list.
  6. Output the value of the variable bird.
  7. Input value in the variable bird.

Question 4

Write C++ statement(s) to do the following:

  1. Declare an array alpha of 50 components of type int.
  2. Initialize each component of alpha to -1.
  3. Output the value of the first component of the array alpha.
  4. Set the value of the twenty-fifth component of the array alpha to 62.
  5. Set the value of the tenth component of alpha to three times the value of the fiftieth component of alpha plus 10.
  6. Use a for loop to output the value of a component of alpha if its index is a multiple of 2 or 3.
  7. Output the value of the last component of alpha.
  8. Output the value of the alpha so that 15 components per line are printed.
  9. Use a for loop to increment every other element (the even indexed elements).
  10. Use a for loop to create a new array, diffAlpha, whose elements are the differences between consecutive elements in alpha.

Question 5

A car dealer has 10 salespersons. Each salesperson keeps track of the number of cars sold each month and reports it to the management at the end of the month. The management keeps the data in a file and assigns a number, 1 to 10, to each salesperson. The following statement declares an array, cars, of 10 components of type int to store the number of cars sold by each salesperson:

int cars[10];

Write the code to store the number of cars sold by each salesperson in the array cars, output the total numbers of cars sold at the end of each month, and output the salesperson number selling the maximum number of cars. (Assume that data is in the file cars.dat, and that this file has been opened using the ifstream variable inFile.)

Question 6

Suppose that you have the following definitions:

struct timeType
{
int hr;
double min;
int sec;

};

struct tourType
{
string cityName;
int distance;
timeType travelTime;
};

  1. Declare the variable destination of type tourType.
  2. Write C++ statements to store the following data in destination: cityName—Chicago, distance—550 miles, travelTime—9 hours and 30 minutes.
  3. Write the definition of a function to output the data stored in a variable of type tourType.
  4. Write the definition of a value-returning function that inputs data into a variable of type tourType.
  5. Write the definition of a void function with a reference parameter of type tourType to input data in a variable of type tourType.

Criteria

Needs Improvement

Satisfactory

Excellent

Points Possible

Delivery

Completed fewer than 80% of the requirements

Not delivered on time, or in the incorrect format

Completed most of the requirements

Delivered on time, and in correct format

Completed 100% of the requirements.

Delivered on time, and in correct format

0-20

Coding Standards

Name, date, or assignment title missing

Poor use of white space (indentation, blank lines)

Disorganized and messy

Poor use of variables (many global variables, unambiguous naming)

Includes name, date, and assignment title

White space makes program fairly easy to read

Organized work

Good use of variables (some global variables, unambiguous naming)

Includes name, date, and assignment title

Excellent use of white space

Efficiently organized work

Excellent use of variables (no global variables, unambiguous naming)

0-20

Documentation

No documentation included

Basic documentation has been completed including descriptions of all variables

Purpose is noted for each function

Clearly and effectively documented including descriptions of all variables

Specific purpose is noted for each function, control structure, input requirements, and output results

0-20

Execution

Program does not execute due to errors

User prompts are misleading or non-existent

Executes without errors

User prompts are understandable

Executes without errors

Excellent user prompts, good use of symbols, spacing in output

0-20

Solution Efficiency

Solution is difficult and inefficient

A logical solution that is easy to follow but is not the most efficient

Solution is efficient, easy to understand, and easy to maintain

0-20


"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.


Discount Code: CIPD30



Click ORDER NOW..

order custom paper