Docsity

software engineerin material, Summaries of Computer Engineering and Programming

Toggle sidebar
bg1
1
Department of Electrical Electronics and
Computer Engineering
SDN150S – Software Design I
Practical 3 Guidelines
INSTRUCTIONS
1. Read the practical guideline and complete all questions.
2. Install Code : Blocks or MS Visual Studio Code. See blackboard resource folder for
further details.
3. Students are expected to complete the practical questions.
4. Submit the following deliverables as your practical 1 assignment on blackboard .
•
A single PDF document containing all your answers.
•
Code saved as a .c file for Question 1 Label the .c file
“Prac03_Question1_StudentNumber”.
•
Code saved as a .c file for Question 2. Label the .c file
“Prac03_Question2_StudentNumber”.
•
Code saved as a .c file for Question 3. Label the .c file
“Prac03_Question3_StudentNumber”.
5. If you submit these deliverables after the deadline, you will lose marks. We have passed
practical 1 question through ChatGPT and looked at multiple solutions generated. If
plagiarism is suspected, students will receive 0% and be sent for a disciplinary hearing in
accordance with the Plagiarism Policy of CPUT.
6. Attend your practical lab session allocated for Friday, between 10:55 – 13:10.
7. Failure to do so will result in a 50% marks deduction.
pf3
pf4

Partial preview of the text

Download software engineerin material and more Summaries Computer Engineering and Programming in PDF only on Docsity!

Department of Electrical Electronics and

Computer Engineering

SDN150S – Software Design I

Practical 3 Guidelines

INSTRUCTIONS

  1. Read the practical guideline and complete all questions.
  2. Install Code : Blocks or MS Visual Studio Code. See blackboard resource folder for further details.
  3. Students are expected to complete the practical questions.
  4. Submit the following deliverables as your practical 1 assignment on blackboard.
    • A single PDF document containing all your answers.
    • Code saved as a .c file for Question 1 Label the .c file “Prac 03 _Question1_StudentNumber”.
    • Code saved as a .c file for Question 2. Label the .c file “Prac 03 _Question2_StudentNumber”.
    • Code saved as a .c file for Question 3. Label the .c file “Prac 03 _Question3_StudentNumber”.
  5. If you submit these deliverables after the deadline, you will lose marks. We have passed practical 1 question through ChatGPT and looked at multiple solutions generated. If plagiarism is suspected, students will receive 0% and be sent for a disciplinary hearing in accordance with the Plagiarism Policy of CPUT.
  6. Attend your practical lab session allocated for Friday , between 10:55 – 13:.
  7. Failure to do so will result in a 50% marks deduction.

Question 1 [ 35 marks] You have been tasked with reprogramming a microcontroller-based temperature monitoring system. This system is designed to monitor and control temperatures in an industrial processing unit. The system currently follows the operational rules below:

  • If temperature < 10°C, activate the heating element.
  • If temperature is between 10°C and 30°C, maintain normal operation (no action needed).
  • If temperature is between 31°C and 50°C, activate the cooling fan.
  • If temperature > 50°C, trigger an overheat alarm.
  • If the input temperature is out of range (-50°C to 100°C), display an error message. 1.1 Re-view the current operational rules above and develop a pseudocode that describes the required actions for programming the microcontroller. The pseudocode should cover.
  • Reading the inputted temperature for each zone.
  • Validating the temperature range.
  • Checking whether both zones have the same or different temperatures.
  • Applying the appropriate control logic based on the given conditions. [ 5 ] 1.2 Write a C program that reads a temperature value and determines whether to activate the cooling fan, heating element, or alarm. Implements conditional statements according to the provided temperature control rules. Validates the temperature range, displaying an error message if the input is invalid. Ensuring your program align directly with your pseudocode. [ 10 ] 1.3 Modify the C program to support dual-zone temperature monitoring and control, allowing two separate units to maintain the same or different temperatures. If both zones have the same temperature, the system should provide a single control response. Otherwise, it should control each zone independently. [ 20 ]
  • Develop another pseudocode with included modifications.
  • Independently monitor and control each zone (Zone 1 and Zone 2).
  • Compare both zones' temperatures after validation.
  • If both zones have the same temperature, display one combined response.
  • If the temperatures are different, control each zone individually.
  • Use logical and relational operators to determine whether zones should be controlled together or separately. Provide a screenshot of your code and attach the .c file in your practical 3 submission.

Provide a screenshot of your full code and answers in a single PDF submission and attach the .c file in your practical 3 submission. BEGIN // Step 1: Define Constants for BMI Ranges using Preprocessor DEFINE UNDERWEIGHT 18. DEFINE NORMAL_WEIGHT 24. DEFINE OVERWEIGHT 29. // Step 2: Get User Input PRINT "Enter weight (kg):" READ weight PRINT "Enter height (m):" READ height // Step 3: Validate Input (Height must be > 0) IF height == 0 THEN PRINT "Error: Height cannot be zero." EXIT PROGRAM END IF // Step 4: Calculate BMI BMI = weight / (height * height) // Step 5: Classify BMI using Conditional Statements IF BMI < UNDERWEIGHT THEN category = "Underweight" flag = 1 // 0001 ELSE IF BMI >= UNDERWEIGHT AND BMI <= NORMAL_WEIGHT THEN category = "Normal Weight" flag = 2 // 0010 ELSE IF BMI > NORMAL_WEIGHT AND BMI <= OVERWEIGHT THEN category = "Overweight" flag = 4 // 0100 ELSE category = "Obese" flag = 8 // 1000 END IF // Step 6: Use Bitwise Operations to Identify Health Warnings PRINT "Your BMI is:", BMI PRINT "Category:", category IF flag & 1 THEN PRINT "Warning: You are underweight. Increase calorie intake." END IF IF flag & 4 THEN PRINT "Warning: Risk of obesity-related diseases. Exercise regularly." END IF IF flag & 8 THEN PRINT "Warning: High risk! Consult a doctor immediately." END IF END