Assignment 5 consists of FOUR (4) exercises: Solved

$24.99 $18.99

Assume language standards compliance and any necessary standard library support unless stated otherwise. These are not trick questions and there is only one correct answer. Basing an answer on actual testing is risky. Place your answers in a plain text “quiz file” named C1A5E0_Quiz.txt formatted as: a “Non-Code” Title Block, an empty line, then the…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

Assume language standards compliance and any necessary standard library support unless stated otherwise. These are not trick questions and there is only one correct answer. Basing an answer on actual testing is risky. Place your answers in a plain text “quiz file” named C1A5E0_Quiz.txt formatted as:

a “Non-Code” Title Block, an empty line, then the answers:

  1. A

  2. C etc.

Personalized C1A5 requirements exclusively for Jose Medrano (U09845800)

C/C++ Programming I (Section 174273)

53

Test Value Sets

54

Set

SHOPPERS

WORST

BEST

MAX_ERRORS

55

A

0

-1

1

2

56

B

3

-3

-3

3

57

C

3

0

0

4

58

D

20

3

15

2

59

E

5

-100

-86

3

60

F

17

-27

9

1

61

62

  1. Submitting your solution

  1. `Send an empty-body email to the assignment checker with the subject line C1A5E1_174273_U09845800

  1. and with your source code file attached.

  1. See the course document titled “How to Prepare and Submit Assignments” for additional exercise

  2. formatting, submission, and assignment checker requirements.

68

69

  1. Hints:

  1. 1. No extra code is necessary to handle the case where the value of SHOPPERS is zero.

  2. 2. See note 6.3 for a similar exercise.

  1. 3. Whenever appropriate, the best way to initialize an automatic array to all zeros is by using the

76

standard syntax:

77

int ratings[CHOICES] = {0};

78

  1. 4. During runtime testing the assignment checker will change the values your code uses for the

  2. SHOPPERS, WORST, BEST, and MAX_ERRORS macros as well as the shopper ratings responses. Make

  3. sure all other code remains valid regardless of the values (within the stated constraints) the

  4. assignment checker uses.

83

  1. 5. Be sure your array contains the correct number of elements. For example, if WORST is -7 and BEST

  2. is 20, the number of elements required (and the value of CHOICES) will be 28.

86

  1. 6. Be sure your algorithm can support zero shoppers, negative rating values, and rating ranges that

  2. do not start or end with zero.

89

  1. 7. Be sure to reset your consecutive range errors counter back to zero each time an in-range

  2. rating is accepted.

  1. C1A5E2 (4 points – C++ Program)

  1. Exclude any source code files that may already be in your IDE project and add three new ones, naming

  2. them C1A5E2_ComputeMinimum.cpp, C1A5E2_ComputeMaximum.cpp, and C1A5E2_main.cpp. Do

  3. not use #include to include any of these three files in each other or in any other file. However, you

  4. may use it to include any appropriate header file(s) you need.

6

7 File C1A5E2_ComputeMinimum.cpp must contain a function named ComputeMinimum and

  1. C1A5E2_ComputeMaximum.cpp must contain a function named ComputeMaximum. Each function

  1. must:

  2. 1. Have exactly two formal parameters, each of type “reference to const double”.

  3. 2. Be declared to return type “reference to double” (not “reference to const double”).

  1. 3. Contain only one statement.

  2. 4. Not use variables other than its formal parameters.

  3. 5. Not use anything that requires #define or #include.

  4. 6. Not use literal values.

  5. 7. Not do assignment, addition, subtraction, multiplication, or division.

  6. 8. Not use if, switch, or looping statements.

  7. 9. Not call functions or macros.

  8. 10. Not display anything.

20

  1. ComputeMinimum must compare the values referenced by its parameters and return a reference to the

  2. smallest value or, if equal, to either. ComputeMaximum must do the same for the greatest value.

23

  1. File C1A5E2_main.cpp must contain function main, which must:

  2. 1. Use no more than two variables.

  3. 2. Use no casts.

  4. 3. Prompt the user to enter two space-separated decimal values on the same line.

  5. 4. Pass references to the user-entered values to both ComputeMinimum and ComputeMaximum as

  6. arguments.

  7. 5. Display the results of both function calls using the following 2-line format, where the question

  8. marks represent the values whose references are passed to and returned from the functions:

32

ComputeMinimum(?, ?) returned ?

33

ComputeMaximum(?, ?) returned ?

34

For example, if the user enters -5.8 5.8 the result should be:

35

ComputeMinimum(-5.8, 5.8) returned -5.8

36

ComputeMaximum(-5.8, 5.8) returned 5.8

37

  1. Do not treat equal values as a special case.

  2. Scientific and standard notation are both okay and may be mixed.

  3. Zeros that don’t affect a fractional part’s value may be omitted.

  4. If a fractional part is empty the decimal point may be omitted.

42

  1. Manually re-run your program several times, testing with at least the following 5 sets of user input values,

  2. where each set represents the argument values in left-to-right order:

45 6.9 6.4 6.4 6.9 -5.8 5.8 -0.0 0.0 8.4e3 6.2e-1

46

47

  1. Submitting your solution

  1. `Send an empty-body email to the assignment checker with the subject line C1A5E2_174273_U09845800

  1. and with your three source code files attached.

  1. See the course document titled “How to Prepare and Submit Assignments” for additional exercise

  2. formatting, submission, and assignment checker requirements.

Personalized C1A5 requirements exclusively for Jose Medrano (U09845800)

C/C++ Programming I (Section 174273)

54

  1. Hints:

  1. Use the conditional operator to both compare the values referenced to by each parameter and

  1. produce the reference that references the greatest value. Return the entire conditional expression

  2. (Note 3.16), type casting it as (double &) to override the “const-ness”. (Same principle as in note 6.12).

1992-2022 Ray Mitchell Page 2 of 2

Personalized C1A5 requirements exclusively for Jose Medrano (U09845800)

C/C++ Programming I (Section 174273)

  1. C1A5E3 (4 points – C++ Program)

  1. Exclude any source code files that may already be in your IDE project and add three new ones, naming

  2. them C1A5E3_ComputeMinimum.cpp, C1A5E3_ComputeMaximum.cpp, and C1A5E3_main.cpp. Do

  3. not use #include to include any of these three files in each other or in any other file. However, you

  4. may use it to include any appropriate header file(s) you need.

6

7 File C1A5E3_ComputeMinimum.cpp must contain a function named ComputeMinimum and

  1. C1A5E3_ComputeMaximum.cpp must contain a function named ComputeMaximum. Each function

  1. must:

  2. 1. Have exactly two formal parameters, each of type “pointer to const double”.

  3. 2. Be declared to return type “pointer to double” (not “pointer to const double”).

  1. 3. Contain only one statement.

  2. 4. Not use variables other than its formal parameters.

  3. 5. Not use anything that requires #define or #include.

  4. 6. Not use literal values.

  5. 7. Not do assignment, addition, subtraction, multiplication, or division.

  6. 8. Not use if, switch, or looping statements.

  7. 9. Not call functions or macros.

  8. 10. Not display anything.

  9. ComputeMinimum must compare the values pointed to by its parameters and return a pointer to the

  1. smallest value or, if equal, to either. ComputeMaximum must do the same for the greatest value.

22

  1. File C1A5E3_main.cpp must contain function main, which must:

  2. 1. Use no more than two variables.

  3. 2. Use no casts.

  4. 3. Prompt the user to enter two space-separated decimal values on the same line.

  5. 4. Pass pointers to the user-entered values to both ComputeMinimum and ComputeMaximum as

  6. arguments.

  1. 5. Display the results of both function calls using the following 2-line format, where the question

  2. marks represent the values whose pointers are passed to and returned from the functions and

  3. the ampersands are displayed literally to remind the user that pointers are being passed and

  4. returned, not the values themselves:

33

ComputeMinimum(&?, &?) returned &?

34

ComputeMaximum(&?, &?) returned &?

35

For example, if the user enters -5.8 5.8 the result should be:

36

ComputeMinimum(&-5.8, &5.8) returned &-5.8

37

ComputeMaximum(&-5.8, &5.8) returned &5.8

38

  1. Do not treat equal values as a special case.

  2. Scientific and standard notation are both okay and may be mixed.

  3. Zeros that don’t affect a fractional part’s value may be omitted.

  4. If a fractional part is empty the decimal point may be omitted.

43

  1. Manually re-run your program several times, testing with at least the following 5 sets of user input values,

  2. where each set represents the argument values in left-to-right order:

46 6.9 6.4 6.4 6.9 -5.8 5.8 -0.0 0.0 8.4e3 6.2e-1

47

48

  1. Submitting your solution

  1. `Send an empty-body email to the assignment checker with the subject line C1A5E3_174273_U09845800

  1. and with your three source code files attached.

  1. See the course document titled “How to Prepare and Submit Assignments” for additional exercise

  2. formatting, submission, and assignment checker requirements.

1992-2022 Ray Mitchell Page 1 of 2 (of C1A5E3)

Personalized C1A5 requirements exclusively for Jose Medrano (U09845800)

C/C++ Programming I (Section 174273)

54

  1. Hints:

  1. Use the conditional operator to both compare the values pointed to by each parameter and produce

  2. the pointer that points to the greatest value. Return the entire conditional expression (Note 3.16), type

  3. casting it as (double *) to override the “const-ness”. (Note 6.12).

1992-2022 Ray Mitchell Page 2 of 2 (of C1A5E3)

Page 8 (7/11/2023)

Assignment 5 consists of FOUR (4) exercises: Solved
$24.99 $18.99