You are on page 1of 5

Late submission due to section change:

Question 1:

#include <iostream>

#include <string>

struct LabData {

std::string labTitle;

std::string labAttendantName;

int labCapacity;

};

int main() {

LabData lab1;

lab1.labTitle = "Lab 1";

lab1.labAttendantName = "John Doe";

lab1.labCapacity = 20;

LabData lab2;

lab2.labTitle = "Lab 2";

lab2.labAttendantName = "Jane Smith";

lab2.labCapacity = 15;

std::cout << "Lab Title: " << lab1.labTitle << std::endl;

std::cout << "Lab Attendant Name: " << lab1.labAttendantName << std::endl;

std::cout << "Lab Capacity: " << lab1.labCapacity << " systems/computers" << std::endl;
std::cout << std::endl; // Add a blank line for separation

// Display information about Lab 2

std::cout << "Lab Title: " << lab2.labTitle << std::endl;

std::cout << "Lab Attendant Name: " << lab2.labAttendantName << std::endl;

std::cout << "Lab Capacity: " << lab2.labCapacity << " systems/computers" << std::endl;

return 0;

……………………………………………………………………….

Question 2:
#include <iostream>

#include <iomanip>
const int NUM_MONTHS = 6;

struct WeatherData {

double totalRainfall;

double highTemperature;

double lowTemperature;

double averageTemperature;

};

int main() {

WeatherData monthlyData[NUM_MONTHS];

for (int i = 0; i < NUM_MONTHS; ++i) {

std::cout << "Month " << i + 1 << std::endl;

std::cout << "Total Rainfall: ";

std::cin >> monthlyData[i].totalRainfall;

std::cout << "High Temperature: ";

std::cin >> monthlyData[i].highTemperature;

std::cout << "Low Temperature: ";

std::cin >> monthlyData[i].lowTemperature;

// Calculate average temperature

monthlyData[i].averageTemperature = (monthlyData[i].highTemperature +
monthlyData[i].lowTemperature) / 2.0;

std::cout << std::endl;

}
double totalRainfall = 0.0;

for (int i = 0; i < NUM_MONTHS; ++i) {

totalRainfall += monthlyData[i].totalRainfall;

double averageRainfall = totalRainfall / NUM_MONTHS;

std::cout << "Weather Data Summary" << std::endl;

std::cout << "-------------------" << std::endl;

std::cout << "Total Rainfall for 6 Months: " << totalRainfall << std::endl;

std::cout << "Average Rainfall per Month: " << averageRainfall << std::endl;

return 0;

You might also like