Go Back   Computer Forums > Welcome To Computer Forums .org > Social Lounge | Off Topic
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 06-27-2007, 09:29 AM   #1
Golden Master
 
joxley1990's Avatar
 
Join Date: Oct 2005
Posts: 7,846
Send a message via AIM to joxley1990 Send a message via MSN to joxley1990
Default VB conversion program commenting..

COULD NOT POST THIS IN COMPUTER PROGRAMMING SECTION, MODS CAN MOVE.


Does anyone know what to comment on this coding for a conversion program?

Code:
' simple program to convert certain variables  

Module conversionprgram
    ' Main method begins execution of VB conversion program
    Sub Main()
        Console.BackgroundColor = ConsoleColor.Black
        Console.ForegroundColor = ConsoleColor.Red


        'declare variables 

        Dim menuoption As Integer = 0
        Dim continueLooping As Char = "y"
        Dim numberforconversion As Integer
        Dim conversionresult As Integer

        Do
            Console.WriteLine("*********************************")
            Console.WriteLine("<Welcome to the conversion program>")
            Console.WriteLine("<Made by  James Oxley>")
            Console.WriteLine("*********************************")
            Console.WriteLine("")
            ' press 1 to convert kilograms to pounds
            Console.WriteLine("To convert Kilograms to Pounds Press 1 ")
            Console.WriteLine("(1kg = 2.205lbs)")
            Console.WriteLine("---------------------------------------")
            Console.WriteLine("")
            ' press 2 to convert pounds to kilograms
            Console.WriteLine("To convert Pounds to Kilograms press 2 ")
            Console.WriteLine("(1lb = 0.454kg)")
            Console.WriteLine("---------------------------------------")
            Console.WriteLine("")
            ' press 3 to convert centimetres to inches
            Console.WriteLine("To convert Centimetres to Inches press 3 ")
            Console.WriteLine("(1cm = 0.394ins)")
            Console.WriteLine("-----------------------------------------")
            Console.WriteLine("")
            ' press 4 to convert inches to centimetres 
            Console.WriteLine("To convert Inches to Centimetres press 4 ")
            Console.WriteLine("(1inch = 2.54cm)")
            Console.WriteLine("-----------------------------------------")
            Console.WriteLine("")
            ' press 5 to convert kilometres to miles
            Console.WriteLine("To convert Kilometres to Miles press 5 ")
            Console.WriteLine("(1km = 0.621miles)")
            Console.WriteLine("---------------------------------------")
            Console.WriteLine("")
            ' press 6 to convert miles to kilometres
            Console.WriteLine("To convert Miles to Kilometres press 6 ")
            Console.WriteLine("1mile to 1.609km)")
            Console.WriteLine("---------------------------------------")
            Console.WriteLine("")
            ' press 7 to convert litres to pints
            Console.WriteLine("To convert Litres to Pint press 7 ")
            Console.WriteLine("(1ltr to 1.758pt)")
            Console.WriteLine("----------------------------------")
            Console.WriteLine("")
            ' press 8 to convert pint to litres
            Console.WriteLine("To convert Pint to Litres press 8 ")
            Console.WriteLine("(1pt to 0.568ltr)")
            Console.WriteLine("----------------------------------")
            Console.WriteLine("")
            ' press 9 to convert fahrenheit to celsius
            Console.WriteLine("To convert Fahrenheit to Celsius press 9 ")
            Console.WriteLine("((f-32)/9)*5")
            Console.WriteLine("------------------------------------------")
            Console.WriteLine("")
            ' press 10 to convert celsius to fahrenheit
            Console.WriteLine("To convert Celsius to Fahrenheit press 10 ")
            Console.WriteLine("((c*9)/5)+32")
            Console.WriteLine("------------------------------------------")
            Console.WriteLine("")
            ' exit after "0" is pressed
            Console.WriteLine("((To exit without making a conversion, press 0))")





            menuoption = Convert.ToInt32(Console.ReadLine())





            If menuoption = 1 Then
                Console.WriteLine("Kilograms to Pounds. Please Enter amount you would like to convert")
                numberforconversion = Convert.ToInt32(Console.ReadLine())
                conversionresult = numberforconversion * 2.205
                Console.WriteLine("conversionresult: {0} Pounds (lbs)", conversionresult)
                Console.WriteLine("Press any key to repeat menu")
                Console.WriteLine("----------------------------")
                Console.ReadKey(True)


            ElseIf menuoption = 2 Then
                Console.WriteLine("Pounds to Kilgrams. Please Enter amount you would like to convert")
                numberforconversion = Convert.ToInt32(Console.ReadLine())
                conversionresult = numberforconversion * 0.454
                Console.WriteLine("conversionresult: {0} Kilograms (kg)", conversionresult)
                Console.WriteLine("")
                Console.WriteLine("")
                Console.WriteLine("Press any key to repeat menu")
                Console.WriteLine("----------------------------")
                Console.ReadKey(True)

            ElseIf menuoption = 3 Then
                Console.WriteLine("Inches. Please Enter amount you would like to convert")
                numberforconversion = Convert.ToInt32(Console.ReadLine())
                conversionresult = numberforconversion * 0.394
                Console.WriteLine("conversionresult: {0} Inches", conversionresult)
                Console.WriteLine("")
                Console.WriteLine("Press any key to repeat menu")
                Console.WriteLine("----------------------------")
                Console.ReadKey(True)

            ElseIf menuoption = 4 Then
                Console.WriteLine("Inches to Centimetres. Please Enter amount you would like to convert")
                numberforconversion = Convert.ToInt32(Console.ReadLine())
                conversionresult = numberforconversion * 2.54
                Console.WriteLine("conversionresult: {0} Centimetres (cm)", conversionresult)
                Console.WriteLine("")
                Console.WriteLine("Press any key to repeat menu")
                Console.WriteLine("----------------------------")
                Console.ReadKey(True)

            ElseIf menuoption = 5 Then
                Console.WriteLine("Kilometres to Miles. Please Enter amount you would like to convert")
                numberforconversion = Convert.ToInt32(Console.ReadLine())
                conversionresult = numberforconversion * 0.621
                Console.WriteLine("conversionresult: {0} Miles", conversionresult)
                Console.WriteLine("")
                Console.WriteLine("Press any key to repeat menu")
                Console.WriteLine("----------------------------")
                Console.ReadKey(True)

            ElseIf menuoption = 6 Then
                Console.WriteLine("Miles to Kilometres. Please Enter amount you would like to convert")
                numberforconversion = Convert.ToInt32(Console.ReadLine())
                conversionresult = numberforconversion * 1.609
                Console.WriteLine("conversionresult: {0} Kilometres (km)", conversionresult)
                Console.WriteLine("")
                Console.WriteLine("Press any key to repeat menu")
                Console.WriteLine("----------------------------")
                Console.ReadKey(True)

            ElseIf menuoption = 7 Then
                Console.WriteLine("Litres to Pint. Please Enter amount you would like to convert")
                numberforconversion = Convert.ToInt32(Console.ReadLine())
                conversionresult = numberforconversion * 1.758
                Console.WriteLine("conversionresult: {0} Pints", conversionresult)
                Console.WriteLine("")
                Console.WriteLine("Press any key to repeat menu")
                Console.WriteLine("----------------------------")
                Console.ReadKey(True)

            ElseIf menuoption = 8 Then
                Console.WriteLine("Pint to Litres. Please Enter amount you would like to convert")
                numberforconversion = Convert.ToInt32(Console.ReadLine())
                conversionresult = numberforconversion * 0.568
                Console.WriteLine("conversionresult: {0} Litres (ltr)", conversionresult)
                Console.WriteLine("")
                Console.WriteLine("Press any key to repeat menu")
                Console.WriteLine("----------------------------")
                Console.ReadKey(True)

            ElseIf menuoption = 9 Then
                Console.WriteLine("Fahrenheit to Celsius. Please Enter amount you would like to convert")
                numberforconversion = Convert.ToInt32(Console.ReadLine())
                conversionresult = ((numberforconversion - 32) / 9) * 5
                Console.WriteLine("conversionresult: {0} Celsius (C)", conversionresult)
                Console.WriteLine("")
                Console.WriteLine("")
                Console.WriteLine("Press any key to repeat menu")
                Console.WriteLine("----------------------------")
                Console.ReadKey(True)
__________________

joxley1990 is offline   Reply With Quote
Old 06-27-2007, 09:29 AM   #2
Golden Master
 
joxley1990's Avatar
 
Join Date: Oct 2005
Posts: 7,846
Send a message via AIM to joxley1990 Send a message via MSN to joxley1990
Default Re: VB conversion program commenting..

Code:
ElseIf menuoption = 10 Then
                Console.WriteLine("Celsius to Fahrenheit. Please Enter amount you would like to convert")
                numberforconversion = Convert.ToInt32(Console.ReadLine())
                conversionresult = ((numberforconversion * 9) / 5) + 32
                Console.WriteLine("conversionresult: {0} Fahrenheit (F)", conversionresult)
                Console.WriteLine("")
                Console.WriteLine("Press any key to repeat menu")
                Console.WriteLine("----------------------------")
                Console.ReadKey(True)


            End If
            ' loop if user requests to
        Loop While menuoption <> 0

    End Sub

End Module
I've got everything commented before the ElseIf options, but I don't know what to comment for the ElseIf coding. My teacher sent me this email, but I don't understand..

Quote:
Originally Posted by My Teacher :)
For the If/Elseif comment blocks you need to explain what the condition that is being checked for true/false is and then within those blocks comment the code that does the actual conversion etc.
__________________

joxley1990 is offline   Reply With Quote
Old 06-27-2007, 01:53 PM   #3
Daemon Poster
 
xtremezx2's Avatar
 
Join Date: Sep 2006
Posts: 915
Default Re: VB conversion program commenting..

for the first part, I think he wants you to tell him what the different options mean and how they are checked. Such as explaining what the 1,2,3.... and however many you have are. The other part he just wants you to tell what the code is doing during the conversion.
xtremezx2 is offline   Reply With Quote
Old 06-27-2007, 02:19 PM   #4
Golden Master
 
joxley1990's Avatar
 
Join Date: Oct 2005
Posts: 7,846
Send a message via AIM to joxley1990 Send a message via MSN to joxley1990
Default Re: VB conversion program commenting..

Quote:
Originally Posted by xtremezx2 View Post
for the first part, I think he wants you to tell him what the different options mean and how they are checked. Such as explaining what the 1,2,3.... and however many you have are. The other part he just wants you to tell what the code is doing during the conversion.
No offense, but did you just post that answer based on the email from my teacher, or do you do VB programming, because it just looks like you have changed the wording of the email..
joxley1990 is offline   Reply With Quote
Old 06-27-2007, 08:08 PM   #5
Daemon Poster
 
xtremezx2's Avatar
 
Join Date: Sep 2006
Posts: 915
Default Re: VB conversion program commenting..

I am a software developer, yes. I guess I don't understand what you don't get about commenting. He's trying to teach you to write out important things so that when you get a job writing software, you can write a piece of code and if something goes wrong with it a year later and your not there to fix it, the person assigned to fix it can understand how it works and what it does. Take a step back and look at it from the view of someone who's never seen it, would you understand everything going on from the comments you've written.
Ex: For your if/else statement you should have something explaining what would make it true and what would make it false, exactly as your teacher asked.
For the 2nd part what I would do it at the start of each block write some comments that explain what conversion is being done, how it's done, and the formula being used.
Hopefully that helps, I don't really feel like going through your whole program and telling you line by line what to write as that would somewhat defeat the purpose of what your teacher is trying to teach you. You seem like a smart guy and I'm sure you'll figure it out, just make sure you explain yourself.
xtremezx2 is offline   Reply With Quote
Old 06-27-2007, 10:29 PM   #6
BSOD
 
Join Date: Jun 2007
Posts: 2,505
Default Re: VB conversion program commenting..

??
Dark Night is offline   Reply With Quote
Old 06-27-2007, 10:41 PM   #7
Fully Optimized
 
CompMan's Avatar
 
Join Date: Aug 2006
Posts: 3,323
Send a message via AIM to CompMan
Default Re: VB conversion program commenting..

^ If you don't know the answer then don't post.

two question marks don't help.
__________________

__________________
|Intel Q6600@3.0ghz||ASUS MAXIMUS FORMULA||2GiG Corsair XM2 DDR2 800||EvGa 8800GTS||36gig Western Digital Raptor 10,000 rpm||Ultra X2 connect 550W modular psu||Thermaltake Tsunami Case|Vista 64bit|
Windows has Blue screens, Mac has grey screens, and CF has White screens!!
2004 Mazda RX-8 GT Titanium Grey, Greddy Exhaust, AEM cold air intake
--objects in rearview get smaller with each shift--
CompMan is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 07:50 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0