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

Write a program that asks the user how many numbers will be entered and then has

ID: 3651675 • Letter: W

Question

Write a program that asks the user how many numbers will be entered and then has the user enter those numbers. When this is done, report to the user the position of the first 8 entered and the last 8 entered. By position we mean, for example, that if the first 8 is the 2nd number entered then its position would be 2. Turn in the following 3 outputs to demonstrate that your program works in each case.

Sample screen output 1:


How many numbers will be entered? 8
Enter num: 5
Enter num: 8
Enter num: 6
Enter num: 8
Enter num: 8
Enter num: 3
Enter num: 7
Enter num: 6
The first 8 was in position 2
The last 8 was in position 5


Sample screen output 2:


How many numbers will be entered? 8
Enter num: 5
Enter num: 2
Enter num: 6
Enter num: 8
Enter num: 1
Enter num: 3
Enter num: 7
Enter num: 6
The first 8 was in position 4
The last 8 was in position 4



Sample screen output 3:


How many numbers will be entered? 8
Enter num: 5
Enter num: 1
Enter num: 6
Enter num: 5
Enter num: 2
Enter num: 3
Enter num: 7
Enter num: 6
Sorry, no eights were entered.


Turn in your source code followed by 3 outputs, one for each of the three sample screen outputs given above.

Explanation / Answer

Inside your loop, change that if block to this: if (number == 8) { if (first == -1) first = loopcount; else last = loopcount; } Before, you were doing this: if (first = -1 && first
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote