我需要帮忙修理我的午餐订单表格代码! [英] I need help fixing my lunch order form code!

查看:74
本文介绍了我需要帮忙修理我的午餐订单表格代码!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码,我无法让它工作:

This is the code that I have and I can't get it to work:

使用System;

使用System.Collections.Generic;

使用System.ComponentModel; < br style ="color:#666666; font-family:'Segoe UI',Helvetica,Garuda,Arial,sans-serif; font-size:14px">
使用System.Data;

使用System.Drawing;

使用System.Linq;

using System.Text;

使用System.Threading.Tasks;

使用System.Windows.Forms;



命名空间Lab10

{

   public partial class Form1:Form

   {

     public Form1()

     {

       InitializeComponent();

    }



     private void button1_Click(object sender,EventArgs e)

     {

       double addon;

       double maincourse;

       double subtotal;

       double total;

       double tax;



       if(radioButton1.Checked)

       {

         maincourse = 6.95;

         addon = 0.75;

      }

       else if(radioButton2.Checked)

       {

         maincourse = 5.95;

         addon = 0.5;

      }

       else if(radioButton3.Checked)

       {

         maincourse = 4.95;

         addon = 0.25;

      }

       subtotal = maincourse;



       if(checkBox1.Checked = true)



         subtotal = subtotal + addon;

       

       if else(checkBox2.Checked = true)

       

         subtotal = subtotal + addon

       

       if else(checkBox3.Checked = true)

        

         subtotal = subtotal + addon      



       tax =(7.75 / 100)* subtotal

       

       total = tax + subtotal



       textBox1.Text = subtotal.ToString;

       textBox2.Text = tax.ToString("#。##");

       textBox3.Text = total.ToString("#。##");

       

    }



     private void button2_Click(object sender,EventArgs e)

     {

       Application.Exit();

    }



     private void checkBox3_CheckedChanged(object sender,EventArgs e)

     {

       clearTotals();



    }



     private void checkBox2_CheckedChanged(object sender,EventArgs e)

     {

       clearTotals();



    }



     private void checkBox1_CheckedChanged(object sender,EventArgs e)

     {

       clearTotals();

    }



     private void radioButton1_CheckedChanged(object sender,EventArgs e)

     {

       groupBox1.Text ="附加项目(每个0.75美元)" ;;

       checkBox1.Text ="生菜,番茄和洋葱";

       checkBox2.Text =" Ketchup,mustard and mayo";

       checkBox3.Text =" French fries";



       clearAddOns();

    }



     private void radioButton2_CheckedChanged(object sender,EventArgs e)

     {

       groupBox1.Text ="附加项目(每个$ 0.50)" ;;

       checkBox1.Text =" Peperoni";

       checkBox2.Text =" Sauces";

       checkBox3.Text =" Olives";



       clearAddOns();

    }



     private void radioButton3_CheckedChanged(object sender,EventArgs e)

     {

       groupBox1.Text ="附加项目(每个$ 0.25)" ;;

       checkBox1.Text =" Croutons";

       checkBox2.Text =" Bacon bits";

       checkBox3.Text =" Bread sticks";



       clearAddOns();

    }



     private void Form1_Load(object sender,EventArgs e)

     {

       groupBox1.Text ="附加项目(每个0.75美元)" ;;

       checkBox1.Text ="生菜,番茄和洋葱";

       checkBox2.Text =" Ketchup,mustard and mayo";

       checkBox3.Text =" French fries";



       clearAddOns();

       checkBox1.Checked = false;

       checkBox2.Checked = false;

       checkBox3.Checked = false;



       clearTotals();

       textBox1.Text ="" ;;

       textBox2.Text ="" ;;

       textBox3.Text ="" ;;



    }

  }

}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Lab10
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            double addon;
            double maincourse;
            double subtotal;
            double total;
            double tax;

            if (radioButton1.Checked)
            {
                maincourse = 6.95;
                addon = 0.75;
            }
            else if (radioButton2.Checked)
            {
                maincourse = 5.95;
                addon = 0.5;
            }
            else if (radioButton3.Checked)
            {
                maincourse = 4.95;
                addon = 0.25;
            }
            subtotal = maincourse;

            if (checkBox1.Checked = true)

                subtotal = subtotal + addon;
            
            if else (checkBox2.Checked = true)
            
                subtotal = subtotal + addon
            
            if else (checkBox3.Checked = true)
               
                subtotal = subtotal + addon           

            tax = (7.75 / 100)*subtotal
            
            total = tax + subtotal

            textBox1.Text = subtotal.ToString;
            textBox2.Text = tax.ToString("#.##");
            textBox3.Text = total.ToString("#.##");
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
            clearTotals();

        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            clearTotals();

        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            clearTotals();
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            groupBox1.Text = "Add-on Item($0.75 each)";
            checkBox1.Text = "Lettuce, tomato and onion";
            checkBox2.Text = "Ketchup, mustard and mayo";
            checkBox3.Text = "French fries";

            clearAddOns();
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            groupBox1.Text = "Add-on Item ($0.50 each)";
            checkBox1.Text = "Peperoni";
            checkBox2.Text = "Sauces";
            checkBox3.Text = "Olives";

            clearAddOns();
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            groupBox1.Text = "Add-on Item ($0.25 each)";
            checkBox1.Text = "Croutons";
            checkBox2.Text = "Bacon bits";
            checkBox3.Text = "Bread sticks";

            clearAddOns();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            groupBox1.Text = "Add-on Item($0.75 each)";
            checkBox1.Text = "Lettuce, tomato and onion";
            checkBox2.Text = "Ketchup, mustard and mayo";
            checkBox3.Text = "French fries";

            clearAddOns();
            checkBox1.Checked = false;
            checkBox2.Checked = false;
            checkBox3.Checked = false;

            clearTotals();
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";

        }
    }
}

推荐答案

乍一看它看起来相当不错(除了可能  clearTotals ()和clearAddOns()方法,这些方法在您发布的代码中不可见。

At first sight it looks reasonably good (except for maybe the clearTotals() and clearAddOns() methods, which are not visible in the code that you posted).

当您说"我无法让它工作"时,精确度是多少你看到的症状是什么?什么是不起作用的,它的行为与预期的不同?

When you say "I can't get it to work", what are the precise symptoms that you are seeing? What is the thing that doesn't work, and how does its behaviour differ from the expected one?


这篇关于我需要帮忙修理我的午餐订单表格代码!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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