Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I hope you can help me. I\'m stuck on my programming assignment andam not sure w

ID: 3619154 • Letter: I

Question

I hope you can help me. I'm stuck on my programming assignment andam not sure what to do. I've completed step 1 fine, but I'm stuckon step 2. Here is the assignment:

Step #1 – And the Payoff is…
The first step for our program will be to compute the payoff; thatis the number of
points a player will get, given a set of values for R1, R2 andR3.
We will start by prompting the user to enter 3 integer valuesbetween 1 and 3 inclusive
for each variable R1, R2 and R3. Make sure that the
program keeps asking the user to re-enter each value until it iswithin acceptable range.
The payoff will be then computed and assigned to a variable named,quite
appropriately, payoff before to be displayed on the screen.
The rules to compute payoff are as follows;
- To start off with, payoff is set to the value of R1
- If R2 is less than than R1, we add its value to payoff. We thenlook at the other
values; if R3 is less than R2, we add twice its value to payoff. Ifnot, if check
whether R3 is less than R1, it this is true, then we add R3 topayoff.
- If R2 wasn’t less than R1, we check whether R3 is less thanR1. If
this is true, we add R3 to payoff.
This is how our game works; no wonder we need a computerprogram.
How do we make sure we have implemented the right way theseconfusing rules? First,
re-reading carefully the code and making sure it implements therequirements. Second,
what about testing with different values of R1, R2 and R3? As partof your work on step
#1, keep track of the tests you used to validate that your programwas working. If a test
helped you find a bug, leave a comment indicating which one.
/* Tests used to validate in step #1;
R1 R2 R3 expected payoff observed payoff
3 3 3 3 5
My 2nd nested IF-ELSE statement had a = instead
Of a == in its Boolean expression!
*/
Step #2 – What is the payoff distribution like?
Ok getting a bit curious here. Now that we know how to compute thepayoff for a given
triplet of values R1, R2 and R3, what about displaying the payofffor all possible triplets?
Modify your program so that, instead of asking the user for values,it uses loops to make
each variable iterate over its valid values. For each possiblevalue of R1, we want to
generate each possible value of R2. For each of these, we want togenerate each possible
value of R3. When we’re there, we compute the payoff for thisspecific triplet of values
and display it on the screen, like so;
1 1 1 payoff is 1
1 1 2 payoff is 1
< Some output removed here to keep this short >
3 3 1 payoff is 4
3 3 2 payoff is 5
3 3 3 payoff is 3

Here is the code that I've written for Step 1:

#include <stdio.h>

int main(void) {
    /*declare R1, R2 and R3*/
    int R1 = 0, R2 = 0, R3 = 0;
  
    /*R1, R2 and R3 are greater strict than 1 andlesser strict than 3*/
    while ((4 <= R1) || (0 >= R1)){
         printf("Enter a value for R1: ");
          scanf("%d" ,&R1);
          }
        
    while ((4 <= R2) || (0 >= R2)){
         printf("Enter a value for R2: ");
          scanf("%d" ,&R2);
          }

    while ((4 <= R2) || (0 >= R3)){
         printf("Enter a value for R3: ");
          scanf("%d" ,&R3);
       }
     
       int payoff = R1;
     
       if (R2 < R1) {
             payoff = R2 + payoff;
             if (R3 < R2) {
                    payoff = (2 * R3) + payoff;
                } else if (R3 < R1) {
                       payoff = R3 + payoff;
                       }
                       } else if (R3 < R1) {
                              payoff = R3 + payoff;
                              }
                                            
       printf("Payoff = %d " ,payoff);
     
/*Tests used to validate in step 1:
R1      R2     R3       EXPECTEDPAYOFF     OBSERVED PAYOFF
2      1      1       4                  4
1      2      3       1                  1
3      1      2       6                  6
2      3      1       3                  3
*/

    system("PAUSE");
    return 0;
}

Is it a matter of changing the loops, or using a switch statement?I understand what step 2 wants, but I have no clue how to getthere. Any help would be greatly appreciated! Thank you!

Explanation / Answer

please rate - thanks you never got back to me step 2 #include int main(void) {     /*declare R1, R2 and R3*/     int R1 = 0, R2 = 0, R3 = 0;     /*R1, R2 and R3 are greater strict than 1 andlesser strict than 3*/ for(R1=1;R1