Help with programming exercise!

Page 1 of 1

5 Replies - 1564 Views - Last Post: 11 November 2011 - 05:02 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=255070&amp;s=4cd7da2f53f6e1dad5023bd0cac5348d&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 Bobthecoder

Reputation: 0
• Posts: 5
• Joined: 26-October 11

Help with programming exercise!

Posted 09 November 2011 - 10:41 PM

Hey guys, I need like a lot of help with this exercise, I know some people will hate on me cuz im a noob lol and I don't except sometime to do the assignment for me but any help would be appreciated.

Exercise:

For this lab you will have to create a Windows Form project that will accept either a Celsius or a Fahrenheit and convert that temperature to the other scale. If a Celsius temperature is entered it will be converted to Fahrenheit and vice versa. Be sure to refer to the attached .exe of our solution to guide you in your planning and development along the way.
It is strongly recommended that you plan your solution by implementing pseudo code or flowchart or both. We will be looking for questions on your solution based on your planning document(s). If you have a question on your code while developing your solution you must be prepared to show us your plan.
Form Requirements:
• Include one text box with an associated label for entry of value to convert.
• Include two radio buttons for selection of temperature scale to convert to, “Celsius” or “Fahrenheit”. When the program starts, or after a Clear operation the default selection should be Celsius.
• Include a label to display the results of the conversion, or an error message on blank entry.
• Include three buttons; one to initiate the conversion of the entered value to the selected temperature scale; one to clear the text box and the results label as well as set the scale back to the default (Celsius) and set the focus in the entry text box; and a third button to exit the program.
• The form should have a non-sizable border style and do not include a control box, min or max buttons.
Conversion Method Design:
• For this lab 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.
• You will have to do a bit of research to find the correct formula for converting from each scale to the other; you can desk check your formula our .exe, we are using the correct formulas.
• 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.
Process as Follows:
• On “Convert Click” you should first test that there is a value entered in the text box, if not, send an error message as our .exe sample does.
If there is a value entered, convert it accordingly and store it in a variable to be used as an argument to your method.
You don’t have to worry about non-numeric, non-blank entries…yet. You should allow entry of real numbers, positive or negative.
• Once you have a value to convert, check which radio button is selected and assign a value to a variable based on that selection.
• Pass the two values held in your temperature and scale variables to your method and be sure to catch the returned value of the method in a variable for use in output.
• Take the new converted temperature value and use it to produce an output message as displayed by our sample .exe.
As usual, for this part of the lab, to be eligible for full marks your application must conform to the requirements as outlined here and the course Style Guide, in this case making sure to include:
• Standard course naming rules and conventions.
• Appropriately declared data types for all possible variables and/or constant(s).
• Strict adherence to the IPO structure in the most efficient manner possible.
• Appropriate and complete program documentation.
• An appropriate, keyboard friendly, user interface design (including tool tips).

Anyways, I'm not that stupid obviously I have designed the program that is the easy part the problem i am having is with the methods and events etc. Here is what I have so far, which I don't think is correct but I attempted it and i'm just on where to continue!

```   private void btnConvert_Click(object sender, EventArgs e)
{
double degree = Convert.ToDouble(txtBox1.Text);

if (degree == null)

```

Is This A Good Question/Topic? 0

Replies To: Help with programming exercise!

#2 acll19

Reputation: 3
• Posts: 63
• Joined: 20-October 10

Re: Help with programming exercise!

Posted 09 November 2011 - 10:57 PM

#3 Bobthecoder

Reputation: 0
• Posts: 5
• Joined: 26-October 11

Re: Help with programming exercise!

Posted 09 November 2011 - 11:05 PM

I hate to say it but yes, like I know I am suppose to be converting something.

#4 acll19

Reputation: 3
• Posts: 63
• Joined: 20-October 10

Re: Help with programming exercise!

Posted 09 November 2011 - 11:13 PM

You know how to get the value from the input text box. Maybe you have trouble finding out which radio is selected.
You just have to do this:
``` if(radioButtonx.cheched)
{
//do something here.
}

```

that's all. The algorithm is written above. You just have to code it.

#5 tlhIn`toq

Reputation: 5874
• Posts: 12,809
• Joined: 02-June 10

Re: Help with programming exercise!

Posted 10 November 2011 - 09:10 AM

If that is all the code you are capbable of writing at this point in the course you REALLY need to talk to your professor and seek tutoring before you fall further behind. There is no way this thread can tutor you in everything you've missed / failed to learn.

See FAQ #15

FAQ (Frequently Asked Questions - Updated Oct 2011

Spoiler

#6 negligible

• D.I.C Regular

Reputation: 62
• Posts: 302
• Joined: 02-December 10

Re: Help with programming exercise!

Posted 11 November 2011 - 05:02 AM

You need to plan out your program. It will help you write it and it will also allow you to easier pinpoint gaps in your understanding/logic.

To ask questions and learn from the answers you need to be more specific and explain why you don't understand a certain thing, for example what exactly confuses you about writing a method.

Here is some basic Pseudo-code that would cover some of your basic requirements, a good way to plan.
It's incomplete, just written to give you the gist of it. The idea is to write the code in a manner you can understand just by reading, you can tweak this as you write it and use it to adjust your logic, as it's easier to see your errors.

```Define new integer as convertValue
Set convertValue to reference value user enters into input textbox.

F2C()
Conversion forumla here

C2F()
Conversion forumla here

On convertButton Push
IF Celsius checkbox is checked
Then Apply F2C() method to convertValue
Then Display result
ELSE
Then Apply C2F() method to convertValue
Then Display result