Results 1 to 11 of 11

Thread: Need help Please!

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2021
    Posts
    2

    Need help Please!

    hello all, i am new to programming and due to circumstances I had to switch my career, I have been in the medical field for the last 7 years and i am transitioning into CIT with a masters in Cyber Security, i am more than lost in intro to programming, i am trying to build an application for one of my problems for class. No help was given from the professor i am on my own and feel completely defeated. i will post the problem and also post my code, if someone would be so kind to direct me or show me if my logic is even correct. thank you.Name:  problem  8.jpg
Views: 352
Size:  28.9 KBName:  code.jpg
Views: 352
Size:  21.7 KBName:  form problem 8.jpg
Views: 319
Size:  30.1 KB


    please any help will be appreciated, hard transitions from medical to computer information technology

  2. #2
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,423

    Re: Need help Please!

    Quote Originally Posted by NewtoProgramming View Post
    hello all, i am new to programming and due to circumstances I had to switch my career, I have been in the medical field for the last 7 years and i am transitioning into CIT with a masters in Cyber Security, i am more than lost in intro to programming
    Hi,

    With regard to the part of your post quoted above, I would recommend obtaining a copy of: -
    Visual Basic .NET for complete beginners. by Ken Carney

    This is available simply by copying the title and author straight into a search engine.


    Poppa
    Along with the sunshine there has to be a little rain sometime.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Need help Please!

    Quote Originally Posted by NewtoProgramming View Post
    if someone would be so kind to direct me or show me if my logic is even correct.
    What logic? This is one of the biggest issues new programmers have. You haven't actually expressed any logic. Beginners try to go straight from an idea to code without actually understanding what the code has to do. That is the logic that they tend to ignore. You should approach any programming problem by first ignoring that it is a programming problem. How would you approach the same problem if you had to do it totally manually? That doesn't require any programming knowledge so being a beginner at programming is not a reason to not be able to do it. Think about the steps you would perform to solve the problem. Pick up a pen and paper and write those steps down. Break the steps down into the smallest units you can and actually perform the steps with different inputs to see whether they produce the expected outputs. When you get to the stage where you have a list of steps that reliably produce the expected outputs regardless of the inputs, you have a working algorithm. That algorithm IS your logic. Only at that point should you consider writing any code and the code you write shouldn't have anything to do with the original problem but, rather, be an explicit implementation of your algorithm. Each step in the algorithm will be very simple so code to implement that step should be 1-3 lines. If it takes more than that then you almost certainly haven't broken down the steps of your algorithm to their simplest state. If you run into a problem that you need us to help you with, you should be able to provide us with your actual logic, i.e. your algorithm, and you should be able to tell us exactly what step you're having trouble with.

    As you get more experienced, you will find that you can generate the algorithm in your head and write code to implement parts of it without having to have the whole algorithm first, but you're still basically following this same process. The fact that it is laborious to do it fully when you're a beginner is not a reason not to do it.

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2021
    Posts
    2

    Re: Need help Please!

    so i finally figured it out. I had a tutor show me where I went wrong and guided me through the problem, thank you for getting back to me, so any problem I should start with manually writing down the problem and then code after

  5. #5
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,235

    Re: Need help Please!

    Not only do you need help in programming you also need guidance as to how to raise an issue on a forum. Do also read a guide as to how to raise a useful request for help...
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: Need help Please!

    Quote Originally Posted by NewtoProgramming View Post
    so i finally figured it out. I had a tutor show me where I went wrong and guided me through the problem, thank you for getting back to me, so any problem I should start with manually writing down the problem and then code after
    It's a good way to go about it. Pretty quickly, you will stop doing that for SOME types of problems, but I have extensive design documents for most programs I have written. In my case, I prefer to write in a word processor (Libre Office, in my case), but that's because I can type fast, so if it is only words, typing is faster than writing, for me. Better still, I can read what I have written afterwards. For anything that requires shapes or calculations, I still use a notepad, though, because neither of those are particularly easy with software....unless I get into using the Surface Pro for sketching, which I have not, yet.
    My usual boring signature: Nothing

  7. #7
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,715

    Re: Need help Please!

    I understand that you've resolved the issue, but I wanted to provide a solution nonetheless for people coming back to this thread. Also, I'm using a console application rather than a desktop (winform) application.

    This is how I would address problem 1:
    Code:
    ' input loop to get the number of llamas
    Console.Write("Number of llamas: ")
    Dim llamaCount As Integer
    Dim llamaCountInput As String = Console.ReadLine()
    Do While Not Integer.TryParse(llamaCountInput, llamaCount)
        Console.WriteLine("Please enter a valid number.")
        Console.Write("Number of llamas: ")
        llamaCountInput = Console.ReadLine()
    Loop
    
    ' determine the cost and print the results
    Dim cost As Integer = If(llamaCount > 99, 100, 250)
    Console.WriteLine("The total cost of {0} llama(s) is {1}", llamaCount, (llamaCount * cost).ToString("C"))
    What this does is at the top is declare two variables to get the user input and then the conversion of the input to an Integer. If the user enters and invalid Integer, then it loops until the user does. At the bottom it calculates the cost by using a ternary if statement, if the number of llamas is greater than 99 then the cost is the first value (100) and if not then the number of llamas is less than or equal to 99 then the cost is the second value (250). Finally it prints the results.

    This is how I would address the second problem:
    Code:
    Dim availableCountries As New Dictionary(Of String, Integer) From {
        { "Peru", 125 },
        { "Chile", 120 },
        { "Brazil", 150 }
    }
    ' input loop to get the country of origin
    Console.Write("Country of origin: ")
    Dim country As String = Console.ReadLine()
    Do While Not availableCountries.ContainsKey(country)
        Console.WriteLine("{0} is not a valid country of origin", country)
        Console.Write("Country of origin: ")
        country = Console.ReadLine()
    Loop
    
    ' get the shipping cost
    Dim shippingCost As Integer = availableCountries(country)
    What this does at the top is declare a dictionary where the key is the country name and the value is the added shipping cost. If the user enters a value that is not a key in the dictionary, then it loops until the user does. Finally it gets the shipping cost by getting the value in the dictionary by its key.

    Here it is all put together:
    Code:
    ' input loop to get the number of llamas
    Console.Write("Number of llamas: ")
    Dim llamaCount As Integer
    Dim llamaCountInput As String = Console.ReadLine()
    Do While Not Integer.TryParse(llamaCountInput, llamaCount)
    	Console.WriteLine("Please enter a valid number.")
    	Console.Write("Number of llamas: ")
    Loop
    
    ' determine the cost
    Dim cost As Integer = If(llamaCount > 99, 100, 250)
    
    Dim availableCountries As New Dictionary(Of String, Integer) From {
    	{ "Peru", 125 },
    	{ "Chile", 120 },
    	{ "Brazil", 150 }
    }
    ' input loop to get the country of origin
    Console.Write("Country of origin: ")
    Dim country As String = Console.ReadLine()
    Do While Not availableCountries.ContainsKey(country)
    	Console.WriteLine("{0} is not a valid country of origin", country)
    	Console.Write("Country of origin: ")
    	country = Console.ReadLine()
    Loop
    
    ' get the shipping cost
    Dim shippingCost As Integer = availableCountries(country)
    
    ' get the total cost and print the results
    Dim totalCost As Integer = shippingCost + cost
    Console.WriteLine("The cost of llamas is {0}. The cost of shipping is {1}. The total cost is {2}.", cost.ToString("C"), shippingCost.ToString("C"), totalCost.ToString("C"))
    Fiddle: https://dotnetfiddle.net/GNg4wo
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Need help Please!

    Quote Originally Posted by NewtoProgramming View Post
    any problem I should start with manually writing down the problem and then code after
    You absolutely should. Not many people do because it is actual work and most people don't really want to do work but rather just want to do the fun part and write code. I include myself in that, when I was a beginner. I learned fairly quickly that trying to go directly from an idea to code is pretty much a guarantee of bad code though. As you get more experienced, you'll become more able to do the algorithm step in your head but you still need a clear idea of what the code needs to do before you actually write code to do it. That's really what this process is about - understanding what the code needs to do first. We see so many questions on this site from people who know nothing about what their code needs to do other than the final result, so they get stuck at some intermediate step because they have no idea what the state should be at that stage. If you understand what the steps are and what the state should be before and after each of those steps, you can write part of your code and then test it to see if it faithfully performs the steps up to that point. It also means that you can write code to perform some of the later steps without having written all the code for the prior steps. For instance, if you determine that there are three steps in your algorithm and you know the expected state before and after each step, you could actually implement the third step first, because you can use the expected state after the second step as your starting point and just write code to go from that state to the final result. You might actually be able to write for all steps but the first, but if you don't understand the steps then that means that you can't do anything at all. If nothing else, having a clear understanding of the process allows you to be very specific when you ask a question here, which means that you'll be far more likely to get the help you want.

  9. #9
    New Member
    Join Date
    Oct 2021
    Posts
    10

    Re: Need help Please!

    Quote Originally Posted by NewtoProgramming View Post
    ... so any problem I should start with manually writing down the problem and then code after
    You can think of "writing it down" as defining the requirements of the system. In your example, the problem given by your professor can be equated to User Requirements. Uncle Thaddeus is the "user", and he needs to know about costs for the llamas. Then, you, as the systems analyst, have to take his User Requirements and create Functional Requirements (the requirements stating how the system shall function to fulfill the User Requirements). The algorithm(s) referenced by jmcilhinney would be your Functional Requirements. Then finally, with your requirements defined - and hopefully signed off on - you write the code.

  10. #10
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,423

    Re: Need help Please!

    It has been said that about 10% of programmers can actually go straight to writing code without writing out the problem first.
    It is also said that about 90% of those other programmers think that they're in that 10%.


    Poppa
    Along with the sunshine there has to be a little rain sometime.

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Need help Please!

    Quote Originally Posted by Poppa Mintin View Post
    It has been said that about 10% of programmers can actually go straight to writing code without writing out the problem first.
    It is also said that about 90% of those other programmers think that they're in that 10%.
    The ones who amuse me are those who come here asking for our help and then do everything they can to avoid acknowledging that they could and should have approached the problem in a different way to begin with. If some people put as much effort into solving a problem as they put into claiming that they did everything they could to solve the problem and any suggestion otherwise is a brutal attack on their character then this site would be a ghost town. I commend the OP here for being so open to the idea that there may be a better way. I would think that anyone would want to be able to solve their own problems as much as possible but the evidence suggests otherwise. This thread has somewhat restored my faith in humanity.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width