Starting from:
$30

$24

Assignment 5 consists of FOUR (4) exercises: Solved

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:

A
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












Submitting your solution



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



and with your source code file attached.



See the course document titled “How to Prepare and Submit Assignments” for additional exercise
formatting, submission, and assignment checker requirements.



68







69

Hints:



1. No extra code is necessary to handle the case where the value of SHOPPERS is zero.
 
2. See note 6.3 for a similar exercise.



 
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


4. During runtime testing the assignment checker will change the values your code uses for the
SHOPPERS, WORST, BEST, and MAX_ERRORS macros as well as the shopper ratings responses. Make
sure all other code remains valid regardless of the values (within the stated constraints) the
assignment checker uses.
83

5. Be sure your array contains the correct number of elements. For example, if WORST is -7 and BEST
is 20, the number of elements required (and the value of CHOICES) will be 28.
86

6. Be sure your algorithm can support zero shoppers, negative rating values, and rating ranges that
do not start or end with zero.
89

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

























































 

C1A5E2 (4 points – C++ Program)



Exclude any source code files that may already be in your IDE project and add three new ones, naming
them C1A5E2_ComputeMinimum.cpp, C1A5E2_ComputeMaximum.cpp, and C1A5E2_main.cpp. Do
not use #include to include any of these three files in each other or in any other file. However, you
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

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



must:
1. Have exactly two formal parameters, each of type “reference to const double”.
2. Be declared to return type “reference to double” (not “reference to const double”).



3. Contain only one statement.
4. Not use variables other than its formal parameters.
5. Not use anything that requires #define or #include.
6. Not use literal values.
7. Not do assignment, addition, subtraction, multiplication, or division.
8. Not use if, switch, or looping statements.
9. Not call functions or macros.
10. Not display anything.
20




ComputeMinimum must compare the values referenced by its parameters and return a reference to the
smallest value or, if equal, to either. ComputeMaximum must do the same for the greatest value.
23

File C1A5E2_main.cpp must contain function main, which must:
1. Use no more than two variables.
2. Use no casts.
3. Prompt the user to enter two space-separated decimal values on the same line.
4. Pass references to the user-entered values to both ComputeMinimum and ComputeMaximum as
arguments.
5. Display the results of both function calls using the following 2-line format, where the question
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


• Do not treat equal values as a special case.
• Scientific and standard notation are both okay and may be mixed.
• Zeros that don't affect a fractional part's value may be omitted.
• If a fractional part is empty the decimal point may be omitted.



42

Manually re-run your program several times, testing with at least the following 5 sets of user input values,
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




Submitting your solution



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



and with your three source code files attached.



See the course document titled “How to Prepare and Submit Assignments” for additional exercise
formatting, submission, and assignment checker requirements. 
 


Personalized C1A5 requirements exclusively for Jose Medrano (U09845800)

C/C++ Programming I (Section 174273)







54

Hints:



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



produce the reference that references the greatest value. Return the entire conditional expression
(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)







C1A5E3 (4 points – C++ Program)



Exclude any source code files that may already be in your IDE project and add three new ones, naming
them C1A5E3_ComputeMinimum.cpp, C1A5E3_ComputeMaximum.cpp, and C1A5E3_main.cpp. Do
not use #include to include any of these three files in each other or in any other file. However, you
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

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



must:
1. Have exactly two formal parameters, each of type “pointer to const double”.
2. Be declared to return type “pointer to double” (not “pointer to const double”).



3. Contain only one statement.
4. Not use variables other than its formal parameters.
5. Not use anything that requires #define or #include.
6. Not use literal values.
7. Not do assignment, addition, subtraction, multiplication, or division.
8. Not use if, switch, or looping statements.
9. Not call functions or macros.
10. Not display anything.
ComputeMinimum must compare the values pointed to by its parameters and return a pointer to the



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

File C1A5E3_main.cpp must contain function main, which must:
1. Use no more than two variables.
2. Use no casts.
3. Prompt the user to enter two space-separated decimal values on the same line.
4. Pass pointers to the user-entered values to both ComputeMinimum and ComputeMaximum as
arguments.



5. Display the results of both function calls using the following 2-line format, where the question
marks represent the values whose pointers are passed to and returned from the functions and
the ampersands are displayed literally to remind the user that pointers are being passed and
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


• Do not treat equal values as a special case.
• Scientific and standard notation are both okay and may be mixed.
• Zeros that don't affect a fractional part's value may be omitted.
• If a fractional part is empty the decimal point may be omitted.



43

Manually re-run your program several times, testing with at least the following 5 sets of user input values,
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




Submitting your solution



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



and with your three source code files attached.



See the course document titled “How to Prepare and Submit Assignments” for additional exercise
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




Hints:



Use the conditional operator to both compare the values pointed to by each parameter and produce
the pointer that points to the greatest value. Return the entire conditional expression (Note 3.16), type
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)

More products