-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtempConversion.cs
More file actions
52 lines (51 loc) · 1.35 KB
/
Copy pathtempConversion.cs
File metadata and controls
52 lines (51 loc) · 1.35 KB
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
/*
Class: CSE 1321
Section: 04
Term: Fall 2023
Instructor: Ermias Memo
Name: Alex Bates
Assignment: Conversion Program
*/
class tempConversion {
private float celsius, fahrenheit, kelvin;
public tempConversion() {
celsius = 0.0f;
fahrenheit = 0.0f;
kelvin = 0.0f;
}
public tempConversion(float celsius, float fahrenheit, float kelvin) {
this.celsius = celsius;
this.fahrenheit = fahrenheit;
this.kelvin = kelvin;
}
public float getCelsius() {return celsius;}
public float getFahrenheit() {return fahrenheit;}
public float getKelvin() {return kelvin;}
public void setCelsius(float celsius) {this.celsius = celsius;}
public void setFahrenheit(float fahrenheit) {this.fahrenheit = fahrenheit;}
public void setKelvin(float kelvin) {this.kelvin = kelvin;}
public float convCtoF() {
fahrenheit = celsius * 9f / 5f + 32f;
return fahrenheit;
}
public float convFtoC() {
celsius = (fahrenheit - 32f) * (5f / 9f);
return fahrenheit;
}
public float convCtoK() {
kelvin = celsius + 273.15f;
return kelvin;
}
public float convKtoC() {
celsius = kelvin - 273.15f;
return celsius;
}
public float convFtoK() {
kelvin = (fahrenheit - 32f) * (5f / 9f) + 273.15f;
return kelvin;
}
public float convKtoF() {
fahrenheit = (kelvin - 273.15f) * (9f / 5f) + 32f;
return fahrenheit;
}
}