d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Help With Simple Visual Basic Console Application > Paying 250fg Or More If Your Fast :)
Add Reply New Topic New Poll
Member
Posts: 2,127
Joined: May 22 2011
Gold: 0.00
Oct 20 2013 06:28pm
If anyone can help me out that would be great. Got some easy visual basic that I am doing in Console Application. I am sure what I am doing is simple wrong but here it is.

HERE IS THE PROBLEM I AM TRYING TO SOLVE. I WILL POST THE CODE I HAVE NOW. IT KEEPS displaying "Sorry no earned day off" and "Sorry no bonus for the month" even when I enter a value that is more that.



5.) Lab 5.5: Write the Visual Basic code for the Store and Employee Bonus Program.
Your program should match your flowcharted solution -- should have a getSales function, determineBonus function, determineDayoff function, and a printInfo sub routine.

Should have 5 functions – main(), getSales(), determineBonus(sales), determineDayOff(sales), and a printInfo() that displays the monthly sales amount and what was earned.

When your flowchart is complete, test the following monthly sales and ensure that the output matches the following. If your output is different, then review your decision statements.

Monthly Sales Expected Output
monthlySales = 102500 You earned a $5000 bonus!
monthlySales = 90000 Sorry – no bonus this month
monthlySales= 112500 You earned a $5000 bonus!
All employees get one day off!!!

CODE:
Code
Module Module1

Sub Main()
Dim sales As double
Dim determineBonus As String
Dim determineDayOff As String

getSales()
determineBonus = bonusCheck(sales)
determineDayOff = checkDayOff(sales)
printInfo(determineBonus, determineDayOff)

End Sub

Function getSales()
Console.WriteLine("Please enter the sales for the month")
getSales = Console.ReadLine()
End Function

Function bonusCheck(ByRef getSales As Double)
Dim determineBonus As String = ""
If getSales >= 102500 Then
determineBonus = "You earned a bonus this month"
End If
If getSales < 102500 Then
determineBonus = "Sorry no bonus for the month"
End If
Return determineBonus
End Function

Function checkDayOff(ByRef getSales As Double)
Dim determineDayOff As String = ""
If getSales >= 112500 Then
determineDayOff = "All employees get a day off!"
End If
If getSales < 112500 Then
determineDayOff = "Sorry no earned day off"
End If
Return determineDayOff
End Function

Sub printInfo(ByVal determineBonus As String, ByVal determineDayOff As String)
Console.WriteLine("Your sales for the month was $" & getSales())
Console.WriteLine("Earned the monthly bonus? " & determineBonus)
Console.WriteLine("Earned day off? " & determineDayOff)
End Sub


End Module


This post was edited by WTFisHIV on Oct 20 2013 06:30pm
Member
Posts: 2,127
Joined: May 22 2011
Gold: 0.00
Oct 21 2013 09:49am
PAYING 1000FG for this answer.
Member
Posts: 5,988
Joined: May 6 2006
Gold: 30.00
Oct 21 2013 02:59pm
These should be passing hte values from getsales, not sales:

determineBonus = bonusCheck(sales)
determineDayOff = checkDayOff(sales)



This post was edited by oOn on Oct 21 2013 03:06pm
Member
Posts: 2,127
Joined: May 22 2011
Gold: 0.00
Oct 21 2013 03:54pm
Quote (oOn @ Oct 21 2013 03:59pm)
These should be passing hte values from getsales, not sales:

determineBonus = bonusCheck(sales)
determineDayOff = checkDayOff(sales)


I got it figured out finally.

Code
Module Module1

Dim determineBonus As String
Dim determineDayOff As String
Dim getSales As Double
Dim sales As Double

Sub Main()
getSales = sales2()
determineBonus = cBonus(getSales)
determineDayOff = checkDayOff(getSales)
printInfo(getSales, determineBonus, determineDayOff)
End Sub

Function sales2()
Console.WriteLine("Please enter the sales for the month")
getSales = Console.ReadLine()
Return getSales
End Function

Function cBonus(ByRef getSales As Double)
Dim determineBonus As String = " "
If getSales >= 102500 Then
determineBonus = "You earned a bonus this month"
End If
If getSales < 102500 Then
determineBonus = "Sorry no bonus for the month"
End If
Return determineBonus
End Function

Function checkDayOff(ByRef getSales As Double)
Dim determineDayOff As String = " "
If getSales >= 112500 Then
determineDayOff = "All employees get a day off!"
Else
determineDayOff = "Sorry no earned day off"
End If
Return determineDayOff
End Function

Sub printInfo(ByRef getSales As Double, ByRef determineBonus As String, ByRef determineDayOff As String)
Console.WriteLine("Your sales for the month was $" & getSales)
Console.WriteLine("Earned the monthly bonus? " & determineBonus)
Console.WriteLine("Earned day off? " & determineDayOff)
End Sub


End Module
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll