CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2012
    Location
    Ireland
    Posts
    9

    Please help with visual basic Project... Car Rental Firm

    I have this VB project to do in my first year at college,with everything else i can't seem to figure out this bit of code.. Here's some information about it.

    Its based on a fictional car hire firm where i have to design a car rental form that an operator fills out while talking to the client on the phone.

    There are a number of vehicles involved,but i will use one as an example here.

    VW Polo- Daily rate... 37.50 weekly rate... 236.25...Fortnightly Rate... 448.90

    Extras.. Child Seat... 22.00 Sat-Nav... 5.00 Roof Rack... 45.00.(client has a choice of one or all)


    If the customer requires the car for 16 days(this number is just an example,it could be any number of days depending on the overall rental period) the cost is calculated by applying the fortnightly rate and adding two extra days at the daily rate.The prices are quoted excluding VAT(20%).

    I have figured out the code that calculates the total number of rental days using the datetimepicker in Visual basic express.

    I have declared the rental rates and cost of extras as constants in the public class
    and vehicle choices are made by clicking on a radiobutton allocated for each vehicle,checkboxes for extras.

    With this information i need to calculate the TOTAL COST of the rental using the MOD operator.

  2. #2
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Please help with visual basic Project... Car Rental Firm

    This is a tricky one, however the simplest solution is to take the Total days.. then going though your rental periods list from longest to shortest, calculate how many periods of each will fulfill the customers requirement.

    EG: given you above example..

    start with 16 days total..
    fortnightly (14 days) : 16/14 == 1 so we have 1 fortnightly value..
    remaining days is easy .. 16 mod 14 = 2 much easier than 16 - (14*1)
    Now we have 2 days left..
    weekly (7 days) : 2/7 == 0 so we have 0 weekly value..
    Daily (1) : well we have 2...

    obviously you will have to watch the maths, as the division will sometimes round up.. but this should give you a good starting point..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  3. #3
    Join Date
    Nov 2012
    Location
    Ireland
    Posts
    9

    Re: Please help with visual basic Project... Car Rental Firm

    Thanks for this dude,the thing is,i'm a complete novice,our lecturer gave us this project to do ater only five lectures with the other modules i'm taking i just can't seem to focus on the this,could you kinda simplify your answer for me,my backs against the wall here and until i finally have the time to focus on this (xmas break)i'm in trouble,the project is due on the 14th of dec... I really don't know what i'm goin to do here

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Please help with visual basic Project... Car Rental Firm

    Looks like what you need is there already.

    Code:
    FN=TotalPeriod/14
    RD=TotalPeriod Mod 14
    WK=RD/7
    DY=RD Mod 7
    The total cost would be FN*fortnightly rate + WK*weeklyrate + dy*dailyrate
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Nov 2012
    Location
    Ireland
    Posts
    9

    Re: Please help with visual basic Project... Car Rental Firm

    Quote Originally Posted by DataMiser View Post
    Looks like what you need is there already.

    Code:
    FN=TotalPeriod/14
    RD=TotalPeriod Mod 14
    WK=RD/7
    DY=RD Mod 7
    The total cost would be FN*fortnightly rate + WK*weeklyrate + dy*dailyrate

    This is the procedure i have for calculating the amount of forthnights,weeks and days.I just seem to have a problem seeing how i would apply this to calculating the total rental charge to the customer from the information i posted earlier regarding the project outline.

    NOD = Number of Days
    NOW = Number of weeks
    NOF = Number of Forthnights
    TAD = Total amount of days.

    Code:
    Dim NOD,NOW,NOF,TAD as Integer
    
    TAD = Integer.Parse(txtTAD.text)
    
    If TAD>= 14 Then
    
    NOF = (TAD - (TAD Mod 14)) / 14
    
    Else if  TAD  <14  Then
    
       NOF = 0
    
    End if
    
    
    If TAD <7 Then
    
    NOW = 0
    
    Else if TAD Mod 14 >6 Then
    
    NOW = 1
    
    Else If TAD Mod 14<7 Then
    
    NOW = 0
    
    End If
    
    If TAD <7 Then 
    
    NOW = TAD
    
    Else
    
    NOD = TAD Mod 7
    
    End If


    I can't seem to come up with the correct code (using the information that is returned useing the above procedure) to calculate the correct total cost to the customer

  6. #6
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Please help with visual basic Project... Car Rental Firm

    That is a lot more code than you need. You have already been shown twice how to do it.

    Based on what you posted you are using VB.Net rather than VB6 so this is the wrong section of the forum.

    Still the method you have been shown will work in VB.Net as well.

    As for the calculation it is just basic math

    TotalRentalCharge=(NumberOfFortNights * FortNightRate) + (NumberOfWeeks*WeeklyRate) + (NumberOfDays*DailyRate)
    Always use [code][/code] tags when posting code.

  7. #7
    Join Date
    Nov 2012
    Location
    Ireland
    Posts
    9

    Re: Please help with visual basic Project... Car Rental Firm

    Thanks for all the help guys,i got that nailed.
    regards Crispan

  8. #8
    Join Date
    Dec 2012
    Posts
    1

    Re: Please help with visual basic Project... Car Rental Firm

    Hi Cristian...

    Already have this project finished, had the same one from the same lect....

    am in cork...

    get back to me :-)

  9. #9
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Please help with visual basic Project... Car Rental Firm

    Bet the professor knows how to search the forums...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  10. #10
    Join Date
    Feb 2013
    Posts
    1

    Re: Please help with visual basic Project... Car Rental Firm

    Quote Originally Posted by dglienna View Post
    Bet the professor knows how to search the forums...
    I'd put money on it.

Tags for this Thread

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

Featured