Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have created a VB.net application, but for some reason none of my calculations

ID: 3646950 • Letter: I

Question

I have created a VB.net application, but for some reason none of my calculations are turning out right. Can someone look over my code and tell me what I need to fix in order to get the calculations to come out correct? Thank you!!

Create an application that calculates and displays the total travel expenses for a buisness trip. The user must provide the following information
Number of days on the trip
Amount of airfare, if any
Amount of car rental fees, if any
Number of miles driven, if a private vehicle was used
Amount of parking fees, if any
Amount of Taxi charges, if any
Conference or seminar registration fees, if any
Lodging charges, per night

The company reimburses travel expenses according to the following policy:
$37.00 per day for meals
parking fees, up to $10.00 per day
Taxi charges up to $20.00 per day
Lodging charges up to $95.00 per day
If a private vehicle is used, $0.27 per mile driven

The application should calculate and display the following:
Total expenses incurred by the business person
The total allowable expenses for the trip
The excess that must be paid by the business person, if any
The amount saved by the business person if the expenses were under the total allowed

The application should have the following functions:
CalcMeals: Calculates and returns the amount reimbursed for meals
CalcMileage: Calculates and returns the amount reimbursed for mileage driven in a private vehicle
CalcParkingFees: Calculates and returns the amount reimbursed for parking fees.
CalcTaxiFees: Calculates and returns the amount reimbursed for taxi charges
CalcLodging: Calculates and returns the amount reimbursed for lodging.
CalcTotalReimbursement: Calculates and returns the total amount reimbursed
CalcUnallowed: Calculates and returns the total amount of expenses that are not allowable, if any. These are parking fees that exceed $10.00 per day, taxi charges that exceed $20.00 per day and lodging charges that exceed $95.00 per day.
CalcSaved: Calculates and returns the total amount of expenses under the allowable amount, if any. For example, the allowable amount for lodging is $95.00 per day. If a business person stayed in a hotel for $85.00 per day for five days, the savings would be $50.00.
Input validation:
Do not accept negative numbers for any dollar amount or for miles driven in a private vehicle. Do not accept numbers less than 1 for the number of days.


My code:

Public Class Form1

Inherits System.Windows.Forms.Form

Const decReMeals As Decimal = 37.0
Const decReParkFees As Decimal = 10.0
Const decReTaxi As Decimal = 20.0
Const decReLodge As Decimal = 95.0
Const decReMiles As Decimal = 0.27
Dim miles As Decimal
Const decReTotal As Decimal = decReMeals + decReParkFees + decReTaxi + decReLodge + decReMiles

Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim intNumberOfDays As Integer
Dim decAirFare As Decimal
Dim decCarRent As Decimal
Dim decMiles As Decimal
Dim decParkFees As Decimal
Dim decTaxi As Decimal
Dim decSemReg As Decimal
Dim decLodge As Decimal
Dim decTotalInc As Decimal
Dim decTotalRe As Decimal
Dim decsaved As Decimal
Dim decTotalExc As Decimal
Try
intNumberOfDays = CInt(CInt(txtNumberOfDays.Text) >= 1)
Catch ex As Exception
MessageBox.Show("Number of days cannot be less than 1.")
Return
End Try
Try
decAirFare = CDec(CDec(txtAirFare.Text) >= 0)
decCarRent = CDec(CDec(txtCarRent.Text) >= 0)
decMiles = CDec(CDec(txtMiles.Text) >= 0)
decParkFees = CDec(CDec(txtParkFees.Text) >= 0)
decTaxi = CDec(CDec(txtTaxi.Text) >= 0)
decSemReg = CDec(CDec(txtSemReg.Text) >= 0)
decLodge = CDec(CDec(txtLodge.Text) >= 0)
Catch ex As Exception
MessageBox.Show("Input amounts cannot be less than zero." & _
" Please enter a zero for any empty fields.", "Imput Error")
Return
End Try
miles = CDec(txtMiles.Text)
Dim totalMilescost As Decimal = miles * decReMiles
decTotalInc = CDec(CDec(txtAirFare.Text) + CDec(txtCarRent.Text) + CDec(txtParkFees.Text) + CDec(txtTaxi.Text) + CDec(txtSemReg.Text) + CDec(txtLodge.Text) + CDec(txtMeals.Text) + totalMilescost.ToString)
txtTotalInc.Text = FormatCurrency(decTotalInc.ToString)
decTotalRe = CalcTotalReimbursement()
txtTotalRe.Text = FormatCurrency(decTotalRe.ToString("c"))
decTotalExc = CalcUnallowed()
txtTotalExc.Text = FormatCurrency(decTotalExc.ToString("c"))
decsaved = CalcSaved(decTotalRe)
txtTotalSav.Text = FormatCurrency(decsaved.ToString)
End Sub
Function CalcMeals(ByRef decReMeals As Decimal) As Decimal
Dim decMealsRe As Decimal
decMealsRe = CDec(txtNumberOfDays.Text) * decReMeals
Return decMealsRe
End Function

Function CalcMileage(ByRef decReMiles) As Decimal
Dim decMilesRe As Decimal
decMilesRe = CDec(txtMiles.Text) * decReMiles
Return decMilesRe
End Function

Function CalcParkingFees(ByRef decReParkFees) As Decimal
Dim decParkFeesRe As Decimal
decParkFeesRe = CDec(txtNumberOfDays.Text) * decReParkFees
Return decParkFeesRe
End Function

Function CalcTaxiFees(ByRef decReTaxi) As Decimal
Dim decTaxiFeesRe As Decimal
decTaxiFeesRe = CDec(txtNumberOfDays.Text) * decReTaxi
Return decTaxiFeesRe
End Function

Function CalcLodging(ByRef decReLodge) As Decimal
Dim decLodgingRe As Decimal
decLodgingRe = CDec(txtNumberOfDays.Text) * decReLodge
Return decLodgingRe
End Function

Function CalcTotalReimbursement() As Decimal
Dim decTotalRe As Decimal
Dim decMealsRe As Decimal
Dim decMilesRe As Decimal
Dim decParkFeesRe As Decimal
Dim decTaxiFeesRe As Decimal
Dim decLodgingRe As Decimal

decMealsRe = CalcMeals(decReMeals)
decMilesRe = CalcMileage(decReMiles)
decParkFeesRe = CalcParkingFees(decReParkFees)
decTaxiFeesRe = CalcTaxiFees(decReTaxi)
decLodgingRe = CalcLodging(decReLodge)
decTotalRe = decMealsRe + decMilesRe + decParkFeesRe + decTaxiFeesRe + decLodgingRe
txtTotalRe.Text = FormatCurrency(decTotalRe)
Return decTotalRe
End Function

Function CalcUnallowed() As Decimal
Dim decTotalExc As Decimal
Dim decTotalInc As Decimal
Dim decTotalRe As Decimal
decTotalExc = decTotalInc - decTotalRe
txtTotalExc.Text = FormatCurrency(decTotalExc.ToString)
Return decTotalExc
End Function

Function CalcSaved(ByRef decTotalRe As Decimal) As Decimal
Dim decSaved As Decimal
Dim decTotalAll As Decimal
decSaved = decTotalRe - decTotalAll
Return decSaved
End Function

Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtNumberOfDays.Clear()
txtAirFare.Clear()
txtCarRent.Clear()
txtMeals.Clear()
txtLodge.Clear()
txtMiles.Clear()
txtParkFees.Clear()
txtSemReg.Clear()
txtTaxi.Clear()
txtTotalInc.Text = String.Empty
txtTotalRe.Text = String.Empty
txtTotalExc.Text = String.Empty
txtTotalSav.Text = String.Empty
txtNumberOfDays.Focus()

End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class

Explanation / Answer

import static java.lang.Integer.*; import static java.lang.Float.*; class expenses { public float Saved, unallowed, Total, total, notall, saving; //Total=0; //total=0; public float CalcMeals(int days) { float meals=days*37; TotalReimb(meals); return meals; } public float CalcMileage(float miles) { float vehicle=miles*0.27f; TotalReimb(vehicle); return vehicle; } public float CalcParkingFees(int days, float park) { float prkng=park; Totalexp(prkng); float prkall=days*10; TotalReimb(prkall); if(prkng>prkall) { notall=prkng-prkall; Unallowed(notall); return prkall; } else { saving=prkall-prkng; Saved(saving); return prkall; } } public float CalcTaxiFees(int days, float taxifee) { float taxiall=days*20; float taxi=taxifee; Totalexp(taxi); TotalReimb(taxiall); if(taxi>taxiall) { notall=taxi-taxiall; Unallowed(notall); return taxiall; } else { saving=taxiall-taxi; Saved(saving); return taxiall; } } public float CalcLodging(int days, float lodge) { float lodgall=days*95; Totalexp(lodge); TotalReimb(lodgall); if(lodge>lodgall) { notall=lodge-lodgall; Unallowed(notall); return lodgall; } else { saving=lodgall-lodge; Saved(saving); return lodgall; } } public void Totalexp(float tote) { Total=Total+tote; System.out.println(Total); } public float CalcTotalexpenses(float airfare, float carent, float seminarfee) { Total=Total+airfare+carent+seminarfee; return Total; } public void TotalReimb(float totr) { total=total+totr; System.out.println(total); } public float CalcTotalReimbursement() { return total; } public void Unallowed(float unall) { unallowed=unallowed+unall; } public float CalcUnallowed() { return unallowed; } public void Saved(float saving) { Saved=Saved+saving; } public float CalcSaved() { return Saved; } } class travel { public static void main(String[] args) { expenses obj=new expenses(); float meals=obj.CalcMeals(parseInt(args[0])); System.out.println("The amount reimbursed for meals is "+meals+"$"); float vehicle=obj.CalcMileage(parseFloat(args[3])); System.out.println("The amount reimbursed for private vehicle is "+vehicle+"$"); float prkng=obj.CalcParkingFees(parseInt(args[0]), parseFloat(args[4])); System.out.println("The amount reimbursed for parking fees is "+prkng+"$"); float taxi=obj.CalcTaxiFees(parseInt(args[0]), parseFloat(args[5])); System.out.println("The amount reimbursed for taxi is "+taxi+"$"); float lodge=obj.CalcLodging(parseInt(args[0]), parseFloat(args[7])); System.out.println("The amount reimbursed for lodging is "+lodge+"$"); float expense=obj.CalcTotalexpenses(parseFloat(args[1]), parseFloat(args[2]), parseFloat(args[6])); System.out.println("The amount he expended for total trip is "+expense+"$"); float reimb=obj.CalcTotalReimbursement(); System.out.println("The total amount reimbursed for him is "+reimb+"$"); float unall=obj.CalcUnallowed(); System.out.println("The amount he expended more than allowed is "+unall+"$"); float saved=obj.CalcSaved(); System.out.println("The amount he saved overall is "+saved+"$"); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote