Note that there are some explanatory texts on larger screens.

plurals
  1. POtemperature calculator
    primarykey
    data
    text
    <p>Hi i am suppose to make a Temperature calculator that will accept either Celsius or perimeter and convert that temperature to the other scale. If a Celsius temperature is entered it will be converted to Fahrenheit and vice versa.</p> <p>Instructions:</p> <blockquote> <p>For this you will have to design and code a method to convert one temperature scale to another and return the result. This single method should take two arguments, one for the temperature value to convert and a second indicating which temperature scale to convert to.</p> <p>Your method should be coded so that it could be accessed by another class or application. Also, make sure there is only one return statement in your method.</p> </blockquote> <p>So far i have created this code but it showing me 2 small errors and i don't know how to fix them.</p> <p>**error 1. Constant value '67' cannot be converted to a 'char'</p> <p>error 2. Constant value '70' cannot be converted to a 'char'**</p> <p>namespace Lab7 { public partial class frmTemperatureConverter : Form { public frmTemperatureConverter() { InitializeComponent(); }</p> <pre><code> private void txtValueToConver_TextChanged(object sender, EventArgs e) { } private void btnConvert_Click(object sender, EventArgs e) { char chr; string str1; string str2; object[] objArray; if (this.txtConvert.Text != "") { double num1 = double.Parse(this.txtConvert.Text); if (this.radCelsius.Checked) { chr = 67; str1 = "farenheit"; str2 = "celsius"; } else { chr = 70; str1 = "celsius"; str2 = "farenheit"; } double num2 = Math.Round(this.ConvertTemperature(num1, chr), 2); this.lblResult.Text = string.Concat(new object[] { num1, " ", str1, " converts to ", num2, " ", str2 }); } else { this.lblResult.Text = "Please enter a numeric temperature to convert."; this.txtConvert.Focus(); } } public double ConvertTemperature(double inTemp, char toScale) { double num; if (toScale == 70) { num = inTemp * 1.80 + 32.00; } else { if (toScale == 67) { num = (inTemp - 32.00) / 1.80; } else { num = inTemp; } } return num; } private void btnClear_Click(object sender, EventArgs e) { this.txtConvert.Text = ""; this.lblResult.Text = ""; this.txtConvert.Focus(); this.radCelsius.Checked = true; } private void btnExit_Click(object sender, EventArgs e) { base.Close(); } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload