CSS 112 Group Assignment
CSS 112 Group Assignment
Instructions:
A group should work for one question, e.g. Grp 1 for Qn 1 Grp 2 for Qn 2, and so on ...
QUESTION 1
QUESTION 2
QUESTION 3
Write a C program that calculates the Body Mass Index (BMI) for a group of students
and categorizes them based on their BMI. The program should prompt the user to
input the number of students and, for each student, their name, age, height (in
meters), and weight (in kilograms). The BMI is calculated using the formula:
BMI = Weight(kg)
Height(m)2
Based on the BMI value, categorize each student as Underweight (BMI < 18.5), Normal
weight (18.5 ≤ BMI < 24.9), Overweight (25 ≤ BMI < 29.9), or Obese (BMI ≥ 30). Display
a table listing each student's name, age, height, weight, BMI, and category.
Additionally, compute and display the average BMI of the class and identify the most
frequent BMI category. Finally, allow the user to select a category (e.g., 1 for
Underweight, 2 for Normal weight, etc.) and display the names of students in that
category. Ensure the program uses arrays to store data and implements modular
programming by using functions for BMI calculation and categorization.
QUESTION 4
Design a C program to manage bus repair records for a company. The system should
allow adding new buses by recording their type, make, registration number, and
owner details, including name, billing address, gender, and contact information. It
should schedule repairs by assigning a mechanic and a helper while logging the type
of repair. Parts required for repairs should be requested from inventory and logged.
The program should calculate the total cost of repairs, including labor hours and
parts, and generate an invoice for the bus owner. It must also maintain a detailed
transaction log that records the date, transaction type (Add, Repair, Billing), repair
type, parts used, and staff involved. The system should provide clear and concise
reports of all transactions on demand. Use structured data (e.g., structs) and modular
functions to ensure an organized and efficient implementation.
QUESTION 5
Suppose patients are visiting a hospital for medical examinations. Each patient
undergoes multiple tests (denoted by "t"). After listening to the patient's symptoms,
medical professionals decide which tests to conduct. Each test incurs a specific cost.
Your task is to write a C program that calculates the total cost of tests for each patient
and categorizes their health condition based on the total amount paid for the tests.
The categories are as follows:
An electronic store wants to keep an inventory of the products in its store. You are
asked to write a C program that asks the user to enter the brand (string, eg. Elba),
serial number (string, eg. ELB102), type (string, eg. kettle), warranty period (int), and
the price (double) for each product. The user can enter as many products information
as needed (use a loop of your choice).
1. Identify the total and average price of all products in the inventory. 2. Display the
brand and model of the most expensive product. 3. How many kettles are in the
inventory?
QUESTION 7
Write a C program that counts the number of words and lines in a text file or from
standard input if no file is specified. The program should take either zero or one
command-line argument: no argument means reading from standard input, while
one argument specifies the file to read. If more than one argument is provided or the
file cannot be opened, the program should print an error message and exit with a
return value of -1. Using fgets(), the program reads the file line by line, and with
strtok(), it tokenizes each line into words, counting both words and lines in the
process. The processLine() function handles the processing of each line. The program
should output the total word count and line count separated by a tab and followed
by a new line. A Makefile must compile the program into an executable named hw1wc
using the -Wall flag to ensure no warnings during compilation.
QUESTION 8
Write a C program that simulates a simple banking application with two accounts:
checking and savings. The program should initialize the balances for both accounts,
display a welcome message along with the initial balances, and provide a menu with
two options: (d) to deposit money or (q) to quit the program. If the user selects (d),
they should be prompted to choose (1) to deposit into the checking account or (2) to
deposit into the savings account. After each deposit, the program should update and
display the balances, and it should also show a record of all transactions made by
the user. The program should exit when the user selects (q) and must handle both
uppercase and lowercase input for menu options.
QUESTION 10
Write a program in C that includes recursive functions for the following tasks:
(1) Check if a given array is a palindrome. For example, arr[] = {2, 1, 1, 1, 2} and
arr[] = {'a', 'b', 'b', 'a'} are palindrome arrays, while arr[] = {1, 5, 4, 3, 2} is not.
(2) Perform operations on 2D arrays using recursion, including (a) swapping rows and
columns, (b) shifting elements of the array, and(c) finding the transpose of the array.
QUESTION 11
Write a C program to assist the head of the Computing Science Studies department at
MU in analyzing student attendance during campus elections. On election day, all
first-year students from the ICT-M, ICT-B, and ITS programs were required to vote,
and their matriculation numbers were recorded as proof of attendance. The program
should allow the user to input the matriculation numbers of all students who voted,
grouped by their respective programs. Once the data is collected, the program should
analyze and display the total number of students who voted from each program (ICT-
M, ICT-B, and ITS) and the overall total number of voters. Additionally, the program
should ensure that each matriculation number is unique and properly validate user
input to prevent errors during data entry.
QUESTION 12