IPC144 – Arrays Solved

$ 20.99
Category:

Description

Workshop 4 (out of 10 marks – 7% of your final grade)

In this workshop, you will code a user-friendly C-language program with an array data structure that processes the elements of the array logically

LEARNING OUTCOMES
Upon successful completion of this workshop, you will have demonstrated the abilities:
• to store data of common type using an array structure
• to associate related data using parallel arrays
• to process the elements of an array using an iteration construct
SUBMISSION POLICY
All your work (all the files you create or modify) must contain your name, Seneca email and student number.
You are responsible to back up your work regularly.
Late submission penalties:
– In-lab portion submitted late, with at-home portion: 0 for in-lab. Maximum of 70/70 for at-home and reflection
– If any of in-lab, at-home or reflection portions is missing the mark will be zero.
IN-LAB: (30%)
Download or clone workshop 4 (WS04) from https://github.com/Seneca-144100/IPC-Workshops
Code a program in a file called temps2.c that does the following:
1- All temperatures entered by the user must be stored in matching (parallel) arrays.

2- Print the title of the application.

>—=== IPC Temperature Calculator V2.0 ===—<

3- Prompt the user to enter the number of days for which the temperature will be tracked. The value entered must be between 3 and 10, inclusive.

Please enter the number of days, between 3 and 10, inclusive:

4- If the user does not enter a value in the correct range, print the following error message:

Invalid entry, please enter a number between 3 and 10, inclusive:

Keep doing this until a valid number is input by the user.

5- Using a for loop, prompt the user to enter the high and low temperature until data is entered for the required number of days, store the values entered in matching arrays:

Day 1 – High: (read user input from stdin*)
Day 1 – Low: (read user input from stdin*)

*stdin: what the user types in (keyboard)

6- When the process is finished, display the values entered.

Output example:
—=== IPC Temperature Calculator V2.0 ===—
Please enter the number of days, between 3 and 10, inclusive: 2
Invalid entry, please enter a number between 3 and 10, inclusive: 4
Day 1 – High: 6

Day 1 – Low: -2
Day 2 – High: 8
Day 2 – Low: -1
Day 3 – High: 7
Day 3 – Low: -3
Day 4 – High: 9
Day 4 – Low: -4

Day Hi Low
1 6 -2
2 8 -1
3 7 -3
4 9 -4

IN_LAB SUBMISSION:
To test and demonstrate execution of your program use the same data as the output example above, including the erroneous entries (the mistakes).
If not on matrix already, upload your temps2.c to your matrix account. Compile and run your code and make sure everything works properly.
Then run the following script from your account: (replace profname.proflastname with your professors Seneca userid)

~profname.proflastname/submit 144_w4_lab <ENTER>
and follow the instructions.

Please Note
• A successful submission does not guarantee full credit for this workshop.

AT_HOME: (30%)
After completing the in_lab section, upgrade your code in temps2.c to:
• display the highest temperature, and the day on which it occurred
• display the lowest temperature, and the day on which it occurred
• calculate and display the mean (average) temperature for a period entered by the user, until the user enters -1.
Output Example
—=== IPC Temperature Calculator V2.0 ===—
Please enter the number of days, between 3 and 10, inclusive: 4

Day 1 – High: 6
Day 1 – Low: -2
Day 2 – High: 8
Day 2 – Low: -1
Day 3 – High: 7
Day 3 – Low: -3
Day 4 – High: 9
Day 4 – Low: -4

Day Hi Low
1 6 -2
2 8 -1
3 7 -3
4 9 -4

The highest temperature was 9, on day 4
The lowest temperature was -4, on day 4

Enter a number between 1 and 4 to see the average temperature for the entered number of days, enter a negative number to exit: 5

Invalid entry, please enter a number between 1 and 4, inclusive: 3

The average temperature up to day 3 is: 2.50

Enter a number between 1 and 4 to see the average temperature for the entered number of days, enter a negative number to exit: 2

The average temperature up to day 2 is: 2.75

Enter a number between 1 and 4 to see the average temperature for the entered number of days, enter a negative number to exit: -1

Goodbye!
AT-HOME REFLECTION (40%)
Please provide brief answers to the following questions in a text file named reflect.txt.
1) In one or two sentences explain why the arrays in this program have to be declared to hold 10 elements?
2) In two or three sentences explain the advantages and disadvantages of using matching arrays?
3) Was the at home portion of this workshop too easy, just right or too hard? Why?
Note: when completing the workshop reflection it is a violation of academic policy to cut and paste content from the course notes or any other published source, or to copy the work of another student.
AT-HOME SUBMISSION
To test and demonstrate execution of your program use the same data as the output example above.
If not on matrix already, upload temps2.c, and reflect.txt to your matrix account. Compile and run your code and make sure everything works properly.
Then run the following script from your account: (replace profname.proflastname with your professors Seneca userid)
~profname.proflastname/submit 144_w4_home <ENTER>

and follow the instructions.

Please Note
• A successful submission does not guarantee full credit for this workshop.

Reviews

There are no reviews yet.

Be the first to review “IPC144 – Arrays Solved”

Your email address will not be published. Required fields are marked *