Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6662035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:20:50+00:00 2026-05-26T02:20:50+00:00

/ At the bottom of this code there are two if statements. I want

  • 0

/At the bottom of this code there are two if statements. I want to be able to check FIRST whether the user has selected a flavor(the text for the flavor textbox is “Select a flavor” by default). If they click the AddDrink button without selecting a flavor, the message box needs to show that they haven’t selected a flavor, instead of haven’t entered a quantity, and then proceed with the program. However, if they have chosen a flavor but haven’t entered a quantity then it should show the message box about entering a quantity. If anymore info is needed please let me know. THANKS FOR YOUR HELP!!!/

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

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

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void ComputeCost_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void btnCompleteOrder_Click(object sender, EventArgs e)
        {
            MessageBox.Show(lblFinalFlavor.Text + "\n" + lblFinalTopping.Text + "\n" + lblFinalCost.Text);
        }

        private void btnAddDrink_Click(object sender, EventArgs e)
        {
            double cost = 0;
            double quantityPrice;
            double quantityNum;
            this.lblFinalTopping.Text = "Extras: ";

            if (this.radSmall.Checked)
            {
                cost += 3.00;
            }
            else if (this.radMedium.Checked)
            {
                cost += 3.50;
            }
            else if (this.radLarge.Checked)
            {
                cost += 4.00;
            }

            if (this.ckBoxCherries.Checked)
            {
                cost += .50;
                this.lblFinalTopping.Text += "Cherries ";
            }
            if (this.ckBoxGrape.Checked)
            {
                cost += .50;
                this.lblFinalTopping.Text += "Grapes ";
            }
            if (this.ckBoxLemon.Checked)
            {
                cost += .50;
                this.lblFinalTopping.Text += "Lemon ";
            }
            if (this.ckBoxPineapple.Checked)
            {
                cost += .50;
                this.lblFinalTopping.Text += "Pineapple ";
            }
            if (this.ckBoxStrawberry.Checked)
            {
                cost += .50;
                this.lblFinalTopping.Text += "Strawberry ";
            }
            if (this.ckBoxVitamin.Checked)
            {
                cost += .50;
                this.lblFinalTopping.Text += "Vitamin Pack ";
            }
            if (this.ckBoxWhipped.Checked)
            {
                cost += .50;
                this.lblFinalTopping.Text += "Whipped cream ";
            }

            this.lblFinalCost.Visible = true;            

            if (this.txtQuantity.Text != "0")
            {
                quantityNum = double.Parse(this.txtQuantity.Text);
                quantityPrice = cost * quantityNum;
                this.lblFinalCost.Text = "Cost: " + quantityPrice.ToString("c");
            }
            else
                MessageBox.Show("Please enter a quantity!");

            if (this.cmboBoxJuiceFlav.Text != "Select a flavor")
                this.lblFinalFlavor.Text = "Flavor: " + this.cmboBoxJuiceFlav.Text;
            else
                MessageBox.Show("Please select a flavor!");
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:20:51+00:00Added an answer on May 26, 2026 at 2:20 am

    Isn’t this what you want:

    if (this.cmboBoxJuiceFlav.Text != "Select a flavor")
    {
        this.lblFinalFlavor.Text = "Flavor: " + this.cmboBoxJuiceFlav.Text;
        if (this.txtQuantity.Text != "0")
        {
            quantityNum = double.Parse(this.txtQuantity.Text);
            quantityPrice = cost * quantityNum;
            this.lblFinalCost.Text = "Cost: " + quantityPrice.ToString("c");
        }
        else
        {
            MessageBox.Show("Please enter a quantity!");
        }
    }
    else
    {
        MessageBox.Show("Please select a flavor!");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the code. I want to align text at bottom <p style=background:#eee;font-size:1.3em;color:#022662;height:116px> <img
This code should i place this code at bottom of body it's in conditional
Update: See the bottom of this question for a C# workaround. Hi there, Consider
When click a button,I want to popup a view form bottom,like this! Any help
UPDATE: First problem solved, second one described at the bottom of this post. UPDATE2:
I have two problem, This nestedSortable is not working in this code, where's the
There are two things I do not understand about this function : 1.Offset not
I have an application in which there are two buttons side-by-side at the bottom
In my page there are two 'Conatct Selected' anchor button, one at the top
The function below was used in two .php documents. This code works perfectly in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.