aboutsummaryrefslogtreecommitdiff
path: root/CST 126/Homework 1/TempLogHelper.hpp
blob: 37ecddf63f51829256131be1e310961807c39511 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#ifndef TEMP_LOG_HELPER_HPP
#define TEMP_LOG_HELPER_HPP

#include "GuessingHelper.hpp"
struct Temperature {
	float High;
	float Low;
};

void DayPrinter(int Choice);
void AvgDiffOutStatement(float Temp, const char* Prompt1, const char* Prompt2, const char* Prompt3);
void HighLowOutStatement(int Choice, float Temp, const char* Prompt1, const char* Prompt2, const char* Prompt3, const char* Prompt4);
float FarenheitToCelsius(float Temp);
void GreatLow(Temperature* WeekLog);
void GreatHigh(Temperature* WeekLog);
void TemperatureAverage(Temperature* WeekLog);
void TemperatureDifference(Temperature* WeekLog);
void WeeklyTemp(const char* Prompt1, const char* Prompt2);

void DayPrinter(int Choice)
{
	switch (Choice)
	{
	case 0:
		std::cout << "Monday";
		break;
	case 1:
		std::cout << "Tuesday";
		break;
	case 2:
		std::cout << "Wednesday";
		break;
	case 3:
		std::cout << "Thursday";
		break;
	case 4:
		std::cout << "Friday";
		break;
	case 5:
		std::cout << "Saturday";
		break;
	case 6:
		std::cout << "Sunday";
		break;
	default:
		std::cout << "Invalid Input!!" << std::endl;
	}
}

void AvgDiffOutStatement(float Temp, const char* Prompt1, const char* Prompt2, const char* Prompt3)
{
	Prompts(Prompt1);
	std::cout << Temp;
	Prompts(Prompt2);
	std::cout << FarenheitToCelsius(Temp);
	Prompts(Prompt3);
	std::cout << " \n" << std::endl;
}

void HighLowOutStatement(int Choice, float Temp, const char* Prompt1, const char* Prompt2, const char* Prompt3, const char* Prompt4)
{
	Prompts(Prompt1);
	DayPrinter(Choice);
	Prompts(Prompt2);
	std::cout << Temp;
	Prompts(Prompt3);
	std::cout << FarenheitToCelsius(Temp);
	Prompts(Prompt4);
	std::cout << " \n" << std::endl;
}

float FarenheitToCelsius(float Temp)
{
	float Celsius = 0.0;

	Celsius = (Temp - 32) * 5 / 9;

	return Celsius;
}

void GreatLow(Temperature* WeekLog)
{
	float GreatestLow = 0.0;
	int Choice = 0u;
	GreatestLow = WeekLog[0].Low;

	for (auto i = 1u; i < 6; i++)
	{
		if (WeekLog[i].Low < GreatestLow)
		{
			GreatestLow = WeekLog[i].Low;
			Choice = i;
		}
	}
	HighLowOutStatement(Choice, GreatestLow, "Your weekly low was on "," with a temperature of ", " degrees Farenheit! That is ", " degrees Celsius");
}

void GreatHigh(Temperature* WeekLog)
{
	float GreatestHigh = 0.0;
	int Choice = 0u;
	for (auto i = 0u; i < 7; i++)
	{
		if (WeekLog[i].High > GreatestHigh)
		{
			GreatestHigh = WeekLog[i].High;
			Choice = i;
		}
	}
	HighLowOutStatement(Choice, GreatestHigh, "Your weekly high was on ", " with a temperature of ", " degrees Farenheit! That is ", " degrees Celsius");
}

void TemperatureAverage(Temperature* WeekLog)
{
	float AverageTemp = 0.0;
	float Sum = 0.0;

	for (auto i = 0u; i < 7; i++)
	{
		Sum += (WeekLog[i].High + WeekLog[i].Low);
	}
	AverageTemp = Sum / 14;

	AvgDiffOutStatement(AverageTemp, "Your weekly average temperature was ", " degrees Farenheit! That is ", " degrees Celsius!");
}

void TemperatureDifference(Temperature* WeekLog)
{
	float HighLowDifference = 0.0;
	float HighLowStorage[7]{};

	for (auto i = 0u; i < 7; i++)
	{
		HighLowDifference = WeekLog[i].High - WeekLog[i].Low;
		HighLowStorage[i] = HighLowDifference;
	}

	float GreatestDifference = 0.0;
	for (auto j = 0u; j < 7; j++)
	{
		if (HighLowStorage[j] > GreatestDifference)
		{
			GreatestDifference = HighLowStorage[j];
		}
	}
	AvgDiffOutStatement(GreatestDifference, "The largest temperature differential was ", " degrees Farenheit! That is ", " degrees Celsius!");
}

void WeeklyTemp(const char* Prompt1, const char* Prompt2)
{
	
	Temperature WeekTemp[7];
	for (auto i = 0u; i <7; i++)
	{
		DayPrinter(i);
		std::cout << "************************************************************************************************************************" << std::endl;
		WeekTemp[i].High = InputFloat(Prompt1);
		WeekTemp[i].Low = InputFloat(Prompt2);
		system("cls");
	}
	TemperatureDifference(WeekTemp);
	TemperatureAverage(WeekTemp);
	GreatHigh(WeekTemp);
	GreatLow(WeekTemp);
}







#endif