Blair Allen Stark

Here is the problem I am working on. It asks me to use the method CalculateCharges, but I don't fully understand how to do this or how it works. I would be grateful for any input.

Lab Problem III

A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $0.50 per hour for each hour or part thereof in excess of three hours.

The maximum charge for any given 24-hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. Develop a console program that calculate and displays the charges for each customer who parked a car in this garage yesterday.

You should input hours parked for each customer. The program should display the charge for the current customer. The program should use the method CalculateCharges to determine the charge for each customer.

The program should input as Double the hours parked by each customer. The program should continue asking for new customer until sentinel value is entered for hours parked.




Answer this question

Blair Allen Stark

  • Holywhippet

    I can't get it to stop looping

    Module modHrsPrked

    Sub Main()

    Dim hrsPrk As Integer

    Dim CalcCharges As Double

    Console.Write("Enter Hours Parked, -1 to quit: ")

    hrsPrk = Console.ReadLine()

    While hrsPrk <> -1

    Console.WriteLine("Total Charges are {0:C}", CalcCharges)

    CalcCharges = hrsPrk

    End While

    Console.Write("Enter Hours Parked, -1 to quit: ")

    hrsPrk = Console.ReadLine()

    End Sub ' Main

    End Module ' modHrsPrked



  • PaulRyan

    I don't think anyone is going to do your homework for you (nor should they) . . .

    that being said, the task is to write a method called 'CalculateCharges' that takes a double as an argument and returns a double as output.

    I hope your course has covered syntax for conditional statements- if/else, select/case - as well as Console input/output, basic string formatting, and method declaration - sub/function.

    Begin by writing 'psuedo-code' for the implementation of your method.



  • Sree Prakash

    wait as second. . . step back. . . look at your previous program

  • lookat

     kevin_estccst wrote:
    Ok, yes I can write a program that says “hello world” [funny].
    Actually I meant that in all seriousness.

    I guess it says something about me personnally when people think I am being funny when I am being serious, and think I am being serious when I am trying to be funny

    I will chaulk that up to the impersonal nature of the internet.

    ok. . . we are going to do what is called a 'functional decomposition' and work our way through the problem. . .but you are going to do the work . . . I will ask you to do something and while what I may ask you to do will not make much sense, when we put it all together, it will. . .

    Do you know the basic syntax for declaring a function

    if you don't, review this link

    I want you to write a function called CalculateCharges. CalculateCharges needs to take a double and return that exact same double. . . yeah I know it sounds useless but work with me here. . . the idea is lets build the program form first, then we will hash out the details.. . .

    so I need to see that you can write  CalculateCharges so that this code


    dim dbl as double

    dbl = CalculateCharges(12.121212)

    Console.WriteLine(dbl)


    outputs 12.121212

    I wont go any further until I know that you can write that code

     



  • Nick Coppola

    Ok, yes I can write a program that says “hello world” [funny]. At least you have a little humor. Procedure is where I start getting lost. Below is one of the programs I wrote for this problem. This is not complete, but it might give you an idea of where I’m at. I also tried to write this with a case select and a byval function, but I keep getting the errors in the calculateCharges part of the program

    Module modHoursParked

    Sub Main()

    Dim hrsParked As Double

    Dim calculateCharges As Integer

    Dim maximum As Integer

    Dim minimum As Integer

    maximum = 10

    minimum = 2

    Console.Write("Enter Hours Parked, -1 to quit: ")

    hrsParked = Console.ReadLine()

    While hrsParked <> -1

    calculateCharges = ((hrsParked - 3) * 0.5) + 2

    If hrsParked >= 16 Then

    Console.WriteLine()

    Console.WriteLine("New balance is {0:C}", maximum)

    End If

    If hrsParked < 4 The

    Console.WriteLine() Console.WriteLine("New balance is {0:C}", minimum)

    Else

    Console.WriteLine()

    Console.WriteLine("Cost for Hours Parked is", calculateCharges)

    End If

    ' prompt user for input and read account number

    Console.WriteLine()

    Console.Write("Enter Hours Parked, -1 to quit: ")

    hrsParked = Console.ReadLine()

    End While

    End Sub ' Main

    End Module ' modHoursParked



  • eric963258741

    Yes, ok its 2 am here also. I will work on it and see you tomorrow afternoon. What time will you be around. Do Until Loop would be my guess. Thanks for all you help. You are the greatest. I learned more in the last six hours than I have all week and I put in some long study hours.

  • amedjones

    Here's what you were wanting the first time around

    Module modPracticeHours

    Sub Main()

    Dim CalcCharges As Double

    Dim hrsPrk As Double

    Console.Write("Enter Hours Parked, -1 to quit: ")

    hrsPrk = Console.ReadLine()

    While hrsPrk <> -1

    CalcCharges = hrsPrk

    Console.WriteLine("Total Charges are {0:C}", CalcCharges)

    Console.Write("Enter Hours Parked, -1 to quit: ")

    hrsPrk = Console.ReadLine()

    End While

    End Sub ' Main

    Function CalcCharges(ByVal hrsPrk As Double) As Double

    Return hrsPrk

    End Function

    End Module ' modPracticeHours



  • known2none

    I'm not expecting you to do my homework. I've put more than 10 hrs into this problem. After that much time I should get an A just for my persistence, but that won't happen. Don't look like I'm going to find much assistance or understanding here either. But I'm not surprized.

  • neostylo

    lets see what you have so far. . . give us an idea as to where you are lost.

    Part of getting proper direction is letting somone know where you are.

    Do you know how to declare a function method

    Can you write a program that writes "Hello World" to the console and waits for the user to hit the [enter] key to exit

    Its ok if you don't. . . we all started right there. At least the good ones did.

    the bad ones started with dropping a label on a form, setting its text to "Hello World", and they think they are programming. . . but I digress. . . we are all here to help.

    "Help me help you. . ."
    j Maguire



  • best one

    Is this what your looking for

    Module Module1

    Sub Main()

    Dim dbl As Double

    dbl = CalculateCharges(12.121212)

    Console.WriteLine(dbl)

    End Sub

    Function CalculateCharges(ByVal dbl As Double) As Double

    Return dbl

    End Function

    End Module



  • citifortune concepts

    I figured out what I did wrong on the continuous loop

  • Yuvaraj_Amar

    exactly . . .

    now. .. lets shape the program. . .

    write me a main program that asks me to insert the number of hours I parked. . .

    it calls this simple CalculateCharges with my input and it writes out the output of caclulate charges . . .foir instance. . .

  • Pranathi

    you are correct, a do loop is most appropriate

    your function is supposed to be called CalculateCharges. . .

    where are you calling your function like you were in the first program I had you write

  • chami602

    I think I already did that. look at the above code and make sure. I’ve renamed things and I have a prompt for the user.



  • Blair Allen Stark