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 6679673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:23:10+00:00 2026-05-26T04:23:10+00:00

Hello I’m a little stuck on a task involving radio buttons. I am using

  • 0

Hello I’m a little stuck on a task involving radio buttons. I am using an else… if statement to determine which radio boxes are checked and I then want a different calculation to be done depending on what radio button is selected from both of the group boxes. In one group box I have 3 options which are items of clothing and the price and in the other group box I have 4 options which are quantities 1-4. When two radio buttons are selected (one from each group box) I would like a calculation to take place. I think my if statements are correct but i’m having trouble doing the calculation and converting it to string as i’ve only ever done calculations using txtboxes which i then convert to int or double and involve them in the calculation. since I’m not using a textbox on this form i’m stumped here is my code:

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

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

    bool blnChecked = true;

    private void btnEnd_Click(object sender, EventArgs e)
    {
        this.Dispose();
    }

    private void btnClear_Click(object sender, EventArgs e)
    {
        lblTotal.Text = "";
        rbtnJeans.Checked = false;
        rbtnQuant1.Checked = false;
        rbtnQuant2.Checked = false;
        rbtnQuant3.Checked = false;
        rbtnQuant4.Checked = false;
        rbtnShirt.Checked = false;
        rbtnShorts.Checked = false;
    }

    private void btnCalculate_Click(object sender, EventArgs e)
    {
        double dbTotal;
        if (rbtnJeans.Checked && rbtnQuant1.Checked)
        {
            dbTotal = Convert.ToDouble(28 * 1);
        }
        else if (rbtnJeans.Checked && rbtnQuant2.Checked)
        {
            dbTotal = Convert.ToDouble(28 * 2);
        }
        else if (rbtnJeans.Checked && rbtnQuant3.Checked)
        {
            dbTotal = Convert.ToDouble(28 * 3);
        }
        else if (rbtnJeans.Checked && rbtnQuant4.Checked)
        {
            dbTotal = Convert.ToDouble(28 * 4);
        }
        lblTotal.Text = "The total cost is: £" + dbTotal.ToString("0.00");
    }
}
}
  • 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-26T04:23:10+00:00Added an answer on May 26, 2026 at 4:23 am

    You are not handling the case where no radio buttons or only one is checked. Initialize dbTotal to zero.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello all i am working on a project in which i have a webpage
Hello I've got this query to get users by email, which is an unique
Hello , I am using arshaw fullcalendar v1.5.2 (only month view ) for property
Hello,I'd like to ask you two questions. (I am using java and jedis) I
Hello I am trying to create a stacked barplot using the following code: test
Hello there am trying to save news tweets into three different array which are
Hello everybody, I'm stuck with a Doctrine join query. The system continues telling me
Hello everyone how can I get two values from different select boxes? I get
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello i been trying to get a tokenizer to work using the boost library

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.