计算会员费 [英] Calculate fees for membership

查看:77
本文介绍了计算会员费的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我正在创建一个图书馆系统,我需要进行计算,并且会员产生了滞纳金.我该如何实现.
他们支付的费用基于延迟天数.例如,没有迟到的天数= 3
charege应该= 2英镑
总费用=£2


请有人可以帮助我完成此任务.

这是我的代码:

I''m creating a library system so far i''ve come to a step where i need to calculate and late fees occured by members. How can i achieve this.
The fee they pay is based on the number of days late. for e.g no days late = 3
charege should = £2
total fee = £2


Please can someone try to help me achieve this task.

here is my code:

Dim latecharge, total As Decimal
Dim days As Integer

If txtdays.Text < 0 Then
    MsgBox("error !", MsgBoxStyle.Critical)
Else

End If

Select Case days
    Case 1 To 5
        txtlate.Text = 2
    Case 6 To 10
        txtlate.Text = 5
    Case 11 To 15
        txtlate.Text = 7.5
    Case 16 To 20
        txtlate.Text = 10
    Case Is > 20
        MsgBox("Remove member")
End Select

latecharge = days
txtlate.Text = latecharge

,但似乎无法正常工作,有人可以指出什么地方出了问题.

but it dont seem to be working can someone kindly point out whats wrong.

推荐答案

基本上,您的代码没有任何意义...
我认为txtDays 是常规的文本框 [ ^ ]可能是未验证.但让我们假设,在此示例中,txtDays 仅可容纳数字值.
如果输入的天数为负,则显示消息框 [ ^ ],我建议使用 MessageBox.Show方法 [ MsgBox [选择案例语句 [
Basically your code makes no sense...
txtDays is, I presume, a regular TextBox[^] that is probably not validated. But let''s assume, for this example, txtDays can only hold numeric values.
If the number of days entered is negative you show a MessageBox[^], may I suggest using the MessageBox.Show Method[^] (.NET) instead of MsgBox[^] (VB).
The next part of your code is a Select Case Statement[^] which checks for the value of the days variable. However, days is never set and thus will always be 0.
So now, let''s say days IS set somewhere, you then show the amount of pounds this person has to pay. Well, I would certainly wait with returning my books, because after 20 days I only get a MessageBox and appearently don''t have to pay for anything :)
The next part of your code is just the weirdest... You''re saying latecharge is equal to days (which still isn''t set) and then txtLate.Text is equal to latecharge... You might as well set txtLate.Text to days immediately. However, since you are using this TextBox to show the fee this person has to pay you are overwriting that value... Besides, the user already knows the days because he or she entered this himself! Also, your total variable does nothing and is just sitting there.
Now consider this:
Dim daysLate As Integer
' Check if the entered value is numeric.
If Not Integer.TryParse(txtDays.Text, daysLate) Then
    MessageBox.Show("Please enter a numeric value.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
    If daysLate < 0 Then
        MessageBox.Show("Please enter a value higher than 0.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
    Else
        Select Case days
            Case 1 To 5
                txtLate.Text = "2"
            Case 6 To 10
                txtLate.Text = "5"
            Case 11 To 15
                txtLate.Text = "7.5"
            Case 16 To 20
                txtLate.Text = "10"
            Case Is > 20
                MessageBox.Show("This member has exceeded the maximum number of days late.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
        End Select
    End If
End If

现在可以了,但是...如果要使用该库您将必须重新编写软件并重新部署,否则将需要不同的费用或天数!因此,我建议您将日期和费用存储在某个地方的数据库中,然后在此处进行恢复...
但是,由于您似乎对如何做和如何做完全迷失了,我建议您首先开始阅读一些书籍.无论是在互联网上还是您正在编写此软件的图书馆中,都有大量参考资料.
顺便问一下,这是家庭作业吗?如果是的话,我建议你再努力一点:)

Now this would work, however... If the library is going to use different fees or days you will have to rewrite your software and re-deploy! So I suggest you store the days and fees in a database somewhere and recover them here...
However, since you seem to be quite lost as to what to do and how to do it I suggest you start reading some books first. There is plenty of reference material, both on the internet and in the library you are writing this software for.
By the way, is this homework? If it is I suggest you study a bit harder :)


这篇关于计算会员费的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆