Search for question
Question

Academic Year 2023/24 Module Title FHEQ_4 UNIVERSITY OF PORTSMOUTH FACULTY OF TECHNOLOGY INTRODUCTION TO ALGORITHMS AND PROGRAMMING - M21387 - Input assessment type here (Coursework (CW)) Submission Instructions Instructions for completing the assessment: Submit your report and source code to the submission links on the Moodle page. Complete all the problems provided in the coursework. Please upload your code in a Text file (.txt) and your report in a Microsoft Word file or PDF file. Your code must be ready to compile. Please test it before submission. Your code must be written in the C programming language. Solutions from other programming languages (C++, python etc) will not be acceptable. Marks and feedback will be provided before or on the day of twenty working days after the submission. If you would like to discuss your mark or feedback further, please use the F&S sessions that run each Tuesday during term time. This coursework (CW) contributes 50% to the ENG421 unit mark. All the specified objectives for the problems must be met to gain full marks on the CW. Missing submission equals zero grade unless you submit and have a valid ECF. Problem 1: Electricity Bill Application You will create an application that will help users calculate their electricity bill following the energy consumed. Write a program that allows a user to insert monthly energy consumption. Following this, your program should be able to calculate the electricity bill from a menu system. You should consider the information provided in Table 1 and equation 1. Your program should allow users: ➤ To choose the user's location from urban or rural options in the menu. To insert their name, house number, email address, phone number, meter number, and the energy (units) consumed per month. ➤ To calculate the monthly electric bill following the energy consumption. ➤ To display their electric bill, which should include all the relevant information of the users. ➤ To save the electric bill as a .txt file. Your program MUST perform precisely as detailed. The functionality of the program must complete the following: 1) Provide a menu system to the user for choosing their location. 2) Allow users to calculate energy bills if they live in urban areas. 3) Allow users to calculate electric bills if they live in rural areas. 4) Allow user to display their electric bill with all the relevant information 5) Allow user to save their electric bill as a .txt file 6) Your application should display informative messages to the users (where appropriate) Unit Consumed (KW) Rural area (Unit Price) Urban area (Unit Price) Between 0 to 50 Between 51 to 100 £2.00 £3.0 £2.75 £3.75 Between 101 to above £4.15 £4.50 Table 1: Per unit price of rural and urban areas based on different unit consumption. [Price = Unit Price * Energy Consumed] ... INTRODUCTION TO ALGORITHMS AND PROGRAMMING -M21387 - FHEQ_4 2023/24 Page 2 of 7 (1) Marking Scheme: 1. Pseudocode: 5 Marks Pseudocode is frequently used by programmers to aid in developing algorithms. It is primarily a marriage between human-like language and actual programming language. Because of its likeness to programming syntax, it has always been more popular among programmers. Following this, provide complete pseudocode of the solution must be written at the top of the program source code and must be enclosed with source code comments delimiters. 5 Marks 2. Source Code: 35 Marks Source code is the fundamental component of a computer program that a programmer creates. In computing, source code is any collection of code, with or without comments, written using a human-readable programming language, usually as plain text. The source code of a program is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source code. Following this, provide complete source code of the solution must be written in C programming language using CodeBlocks. Your code must be ready to compile, so please test it before submission. 1) Menu System 2) Calculate electric bills for urban areas. 3) Calculate electric bills for rural areas. 4 Marks 4 Marks 4 Marks 4) Display electric bill with all the relevant information 4 Marks 5) Save electric bill as .txt file 6) Informative message to the user 7) Efficient use of C programming knowledge 5 Marks 4 Marks 10 Marks Problem 2: Investigate Energy Consumption Internet of Things (IoT) devices that use multiple sensors, actuators, etc are finding their way into our homes at an alarming rate. The need to store, access, and analyse the data from these devices becomes increasingly a top priority, mainly due to the requirement to provide real-time monitoring of activities happening within the home. In this assignment, you will develop an active control system with the following specifications: 1. Read data captured from IoT devices that have been stored in text files. The files contain a day's worth of data captured at hourly intervals. You are required to use the code provided (in the appendix below) but adapt it to make use of structures. INTRODUCTION TO ALGORITHMS AND PROGRAMMING -M21387 - FHEQ_4 2023/24 Page | 3 of 7 2. Process data to activate/deactivate devices. The sensor data is used either to turn ON or OFF devices within the rooms being monitored 3. Display state of devices based on location and/or time. The following devices are used as part of the home monitoring system: • Humidity sensors (used to turn ON or OFF a ventilation system) ● Internal and external temperature sensors (used to turn ON or OFF a heating system) Motion sensors (used to turn ON or OFF lights in that room) Data Files The data files containing the days' worth of information have been provided (on the Moodle assignment link) and contain information at which the sensor data has been recorded. The files are named per the location where the data was recorded. Each text file contains information in the following order: timestamp, outside temperature and inside temperature, humidity, and motion sensors (6 samples over a 1-hour slot i.e. one sample every 10 minutes) timestamp outside inside humidity motion sensors temperature temperature 10 m 20 m 30 m 40 m 50 m 60 m 00:33:44 11.5 15.7 57.2 9.5 10.7 7.5 9.5 7.1 11.5 01:33:44 8.5 18.8 41.5 11.6 9.5 9.6 10.7 8.5 10.5 02:33:44 10.4 13.5 49.5 9.5 7.5 11.8 10.5 7.7 03:33:44 10.9 15.5 59.5 8.5 7.7 9.5 7.5 10.5 11.9 11.5 04:33:44 9.8 14.5 57.3 9.5 10.2 8.5 11.5 11.9 9.2 Three files are available for data recorded in the living room, bedroom and kitchen (Please find the file on Moodle). The data loaded from these files are then used to: 1. Decide wherever to turn ON or OFF the associated device (e.g. heating, ventilation, and lights) 2. Compute the energy consumption based on how long the devices have been ON on a daily basis. Daily consumption in per KiloJoules (KJ) is calculated using equation 2.0 below Daily Consumption (KJ) = Daily Heating Energy + Daily Ventilation Energy + Daily Light Energy Equation 2.0 Energy Consumption INTRODUCTION TO ALGORITHMS AND PROGRAMMING -M21387 - FHEQ_4 2023/24 Page 4 of 7 The information in Table 2.0 indicates the amount of energy consumed per hour when the respective devices are ON. Table 2.0 Energy Consumption Heating 150 KJ Ventilation 125 KJ Lights 100 KJ Functionality and Marking Scheme Your program will need the following functionality: 1. Read/load data from sensor files provided using the ReadDataFunction provided in Appendix (See page 5). ➤ Note you will need to request the user to provide a file location as a string for each file before running this function. a. TimeDat[] for the time b. TempArr[][] for the temperatures c. HumiArr[] for humidity d. MotionArr[][] for motion sensors (10 marks for loading data successfully from all three files) 2 marks 2 marks 2 marks 2 marks 2 marks Your system should therefore provide a menu system that provides options to the user by using functions for the following: 2. Control the state of the devices Control the state of the devices (turn ON or OFF) based on the user's specifications. 5 marks It is expected the user will supply a threshold for each device, regardless of location, to turn ON 5 marks INTRODUCTION TO ALGORITHMS AND PROGRAMMING -M21387 - FHEQ_4 2023/24 Page | 5 of 7