Create your own simple program using a repetition structure- Computer Engineering

Create your own simple program using a repetition structure- Computer Engineering

While-End Loop (Repetition Structure)

 

1592_Figure.png

Create your own simple program using a repetition (i.e., Loop) structure. You decide the theme. Provide an overview (i.e., Program Design) of what your repetition structure is doing. Then provide the Pseudocode of your example.  Please keep the design simple for this exercise. Just a few lines of code is all that is needed for this response.

First, write using a for loop for a fixed number of loops.

Then for the same program use a While loop with a sentinel approach.

When using the While loop, you will need some logic to exit the loop and you will need a loop counter.

You could take one of your prompts from Road Trip and create a loop around it.

I don’t want to see just a loop where you just print out the loop counter.

Some suggestions:

1) Prompt for mileage run daily, count the days, and calculate the ave miles per day, display total miles and ave daily miles

2) Prompt for grocery costs per week, count the weeks, calculate the ave grocery costs per week, display total grocery costs and ave grocery costs

3) Prompt for car miles driven in a month, count the months, and calculate the ave miles driven per month, display total miles and ave monthly miles driven

4) Prompt for number of movie tickets sold in a night, count the number of nights, calculate the ave tickets sold per night, display the total tickets sold and the ave tickets sold per night.

Remember— The accumulation of total is done inside the loop. To calculate ave you divide the accumulated total by the number of whatever you are looping. The ave is done after the end of the loop.

2: Convert Part 1 to C-code. You only need to do one of the loop types.  Don’t for get to indent your code.  Put Part 2 – problem no. X in the Subject area and submit a .txt (or .c) file for your code.

3: Take your While-End repetition structure from Part 1 and modify it so that the While condition test uses a Boolean variable. You will need to initialize the Boolean variable prior to the loop as well as set it inside the loop so that you exit the loop appropriately.

Order from us and get better grades. We are the service you have been looking for.