可以在作业上使用一些帮助。 [英] Could use some help on an assignment.

查看:74
本文介绍了可以在作业上使用一些帮助。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是作业: 

Here is the assignment : 

Novelty Warehouse需要一个允许用户输入商品价格的应用程序。当用户点击界面中的按钮
时,按钮Click事件过程应该将价格加到已经输入的价格总和中;此金额代表客户所欠的小计。应用程序应在屏幕上显示小计。它还应该显示
3%的销售税,运费以及客户所欠的总额。总计是通过将小计,3%销售税和15美元的运费加在一起计算的。例如,如果用户输入26.75作为价格,然后单击
按钮,按钮Click事件过程应显示26.75作为小计,.80作为销售税,15.00作为运费,42.55作为运费累计。如果用户随后输入30.00作为价格,然后单击按钮,按钮单击
事件过程应显示56.75作为小计,1.70作为销售税,15.00作为运费,73.45作为总计。但是,当小计至少为100美元时,运费为0(零)。 

---------- -------------------------------------------------- -------------

-------------------------------------------------------------------------

这是我目前的代码。我不知道如何让程序从第一个输入存储它的内存 并添加连续输入。 我试图在全局级别声明变量,但它仍然不起作用。我不知道
会做什么。 

Here is the code I currently have. I am not sure how to make the program store its memory from the first input  and add consecutive inputs.  I tried to declare the variables on the global level, but it still does not work. I am not sure what to do. 

Public Class Form1

    Dim num1 As Double
    Dim num2 As Double
    Dim subtotal As Double
    Dim totaldue As Double
    Private Sub CalculateButton_Click(sender As Object, e As EventArgs) Handles CalculateButton.Click

        Dim salestax As Double
        Dim shipping As Double

        Double.TryParse(ItemPricetxt.Text, subtotal)

        subtotalTxt.Text = subtotal
        num1 = subtotal

        salestax = subtotal * 0.03
        salesTaxtxt.Text = salestax.ToString("C2")
        If subtotal < 100 Then
            shipping = 15
        Else
            shipping = 0
        End If
        totaldue = shipping + subtotal + Val(salesTaxtxt.Text)
        shippingTxt.Text = shipping.ToString("C2")
        TotalDueTxt.Text = totaldue.ToString("C2")
        subtotalTxt.Text = subtotal.ToString("C2")






    End Sub




推荐答案


我不知道如何让程序存储其内存从第一次输入 并添加连续输入。

I am not sure how to make the program store its memory from the first input  and add consecutive inputs.

您是指ItemPricetxt文本框中的输入吗?

Do you mean the input in the ItemPricetxt text box?

使用以下示例该方法的参考:

https:/ /msdn.microsoft.com/en-us/library/994c0zb1(v=vs.110).aspx

Use the example from the reference for the method:
https://msdn.microsoft.com/en-us/library/994c0zb1(v=vs.110).aspx

        If Not Double.TryParse(ItemPricetxt.Text, subtotal) Then
            'User input was not valid 
            MsgBox("Please enter a valid sales amount")
            Exit Sub
        End If
        'subtotal (a numeric variable) is now available for your calculation.


对于"连续输入",您需要确定要累积的内容。  ;您需要一个简单的销售价格,shippig和税收总额吗? 如果是,请为这些总计创建一些全局漫画,并在每个按钮末尾添加总计单击
event。 或者,您是否需要保留每个销售价格的记录?  如果您累积每个销售价格,那么您可以从一系列简单的销售价格中重新计算每个运费和税收。  如果你想累积销售价格,运费和税金
那么最好的选择是一个List(你可以创建一个自定义类来将这三个数据项收集到一个实例中。

For 'consecutive inputs' you need to decide what you want to accumulate.  Do you need a simple total of sale price, shippig and tax?  If so, create some global cariables for these totals, and add to the totals at the end of each button click event.  Or, do you need to maintain a record of each one?  If you accumulate each sale price then you can recalculate each shipping and tax from a simple array of sale prices.   If you want to accumulate sale price, shipping and tax then the best option is a List(Of a custom class that you can create to gather those three data items into a single instance.


这篇关于可以在作业上使用一些帮助。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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