帮助完成编程II的任务 [英] Help with an assignment for programming II

查看:72
本文介绍了帮助完成编程II的任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!


我有一项创建销售应用程序的任务,该应用程序执行以下操作:


数量折扣 


1 0-19
    20% 

20-49    30% 

50-99    40% 

> = 100    50% 


每个单位售价99美元。显示折扣金额,计算全价后的折扣并应用正确的折扣,
以及您将支付的总金额。


它将有一个输入文本框和一个计算按钮,然后是3个输出标签。第一个标签会告诉你你得到的折扣
。根据您在文本框中的输入,您将获得20%,30%,40%或50%。然后,下一个标签必须显示您的总节省。因此,它将计算您的初始文本框输入乘以99,然后应用适用的百分比折扣。
最终标签将在节省后显示您的总价格。



因为所有这个应用程序我遇到了很多麻烦计算和变量。我应该在此作业中使用if / else
语句。 



这是我到目前为止所拥有的。我很确定它已经过时了。我感谢你们提供的任何帮助!谢谢!



private void calculateButton_Click(object sender,EventArgs e)

        {

            //如果#of包是10-19,则是20%的折扣

            //如果#of包是20-49,则是30%的折扣 

            //如果#of包是50-99,那么它是40%的折扣

            //如果#of的包裹是> = 100,那就是50%的折扣



            const decimal TWENTY = .2m;

            const decimal THIRTY = .3m;

            const decimal FORTY = .4m;

            const decimal FIFTY = .5m;



           双重零售;  

           双倍折扣; //保持折扣率

           双重保存;        //保存已存入的金额

           双倍总数;        //保留折扣后的总额

           双重购买;    //持有购买的单位   



            purchase = double.Parse(purchaseTextBox.Text);

            retail =购买* 99;

            

$


            //计算来自purchaseTextBox的数据



  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(购买< = 19&& purchase> = 10)

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; discountLabel.Text =" 20%"; $
  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; discountrate = .2;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; savedLabel.Text = retail.ToString(" c");
$


  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }


  &NBSP; &NBSP;   else if(购买> =&&购买< = 49) 

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; discountLabel.Text =" 30%";


  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }


  &NBSP; &NBSP;   else if(购买> = 50&&购买< = 99) 

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; discountLabel.Text =" 40%"; $
  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; discountrate = .4;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }


  &NBSP; &NBSP;   else if(buy> gt = 100) 

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; discountLabel.Text =" 50%"; $
  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; discountrate = .5;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }




解决方案

你的等级是多少?


"我有一项创建销售应用程序以执行以下操作的任务"


学校,大学或大学?


Hello!

I have an assignment to create a sales app that does the following:

Quantity Discount 

10–19    20% 
20–49    30% 
50–99    40% 
>=100    50% 

Each unit costs $99. Display the discount amount, the discount after calculating the full price and applying the correct discount, and the total amount you will pay.

It will have an input text box and a calculate button, and then 3 labels of output. The first label will tell you which discount you get. Depending on your input in the text box, you will either get 20%, 30%, 40%, or 50%. Then, the next label has to display your total savings. So it will calculate your initial text box input multiplied by 99, then apply whichever % discount applies. The final label will display your total price after the savings is applied.

I am having a lot of trouble with this application because of all the calculations and variables. I am supposed to be using if/else statements in this assignment. 

Here is what I have so far. I am pretty sure it is way off. I appreciate any help you guys can provide! Thanks!

private void calculateButton_Click(object sender, EventArgs e)
        {
            //if the #of packages is 10-19, it is a 20% discount
            //if the #of packages is 20-49, it is a 30% discount 
            //if the #of packages is 50-99, it is a 40% discount
            //if the #of packages is >=100, it is a 50% discount

            const decimal TWENTY = .2m;
            const decimal THIRTY = .3m;
            const decimal FORTY = .4m;
            const decimal FIFTY = .5m;

            double retail;  
            double discountrate; //to hold the discount rate
            double saved;        //to hold the amount saved
            double total;        //to hold the total after discount
            double purchased;    //to hold the purchased units   

            purchased = double.Parse(purchasedTextBox.Text);
            retail = purchased * 99;
            


            //calculate the data from purchasedTextBox

            if (purchased <=19 && purchased >= 10)
            {
                discountLabel.Text = "20%";
                discountrate = .2;
                savedLabel.Text = retail.ToString("c");

            }

       else if (purchased >= 20 && purchased <= 49) 
            {
                discountLabel.Text = "30%";

            }

       else if (purchased >= 50 && purchased <= 99) 
            {
                discountLabel.Text = "40%";
                discountrate = .4;
            }

       else if (purchased >= 100) 
            {
                discountLabel.Text = "50%";
                discountrate = .5;
            }


解决方案

What is your level?

"I have an assignment to create a sales app that does the following"

School, college or university?


这篇关于帮助完成编程II的任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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