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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:05:45+00:00 2026-06-12T21:05:45+00:00

I have to programming a triangle-calculator, that can calculate from three given values all

  • 0

I have to programming a triangle-calculator, that can calculate from three given values all the other missing information’s. I do know how I can calculate the values – that isn’t the problem.
But I don’t know, how I can programming that in a good way.

The interface looks like this:

enter image description here

With this 12 input-fields there are many possible combinations. My first idea was to use if/else statements for every combination. But that is not very efficient.
I’am sure, that there is a better solution, but I don’t know how.
Can anybody help me?

EDIT
My code looks at the moment so:

protected void FlaecheBerechnen_Click(object sender, EventArgs e)
    {     
        WerteAuslesen();
        Berechnen();
    }

    protected void WerteAuslesen()
    {
        //Sides
        string strSeite_a = this.txt_a.Text; if (strSeite_a == string.Empty) { i++; } else { if ((double.TryParse(strSeite_a, out seite_a) == false)) { GenerateErrorReport("Seite a"); } }
        string strSeite_b = this.txt_b.Text; if (strSeite_b == string.Empty) { i++; } else { if ((double.TryParse(strSeite_b, out seite_b) == false)) { GenerateErrorReport("Seite b"); } }
        string strSeite_c = this.txt_c.Text; if (strSeite_c == string.Empty) { i++; } else { if ((double.TryParse(strSeite_c, out seite_c) == false)) { GenerateErrorReport("Seite c"); } }

        //Angles
        string strWinkel_a = this.txtAlpha.Text; if (strWinkel_a == string.Empty) { i++; } else { if ((double.TryParse(strWinkel_a, out winkel_a) == false)) { GenerateErrorReport("Winkel Alpha"); } }
        string strWinkel_b = this.txtBeta.Text; if (strWinkel_b == string.Empty) { i++; } else { if ((double.TryParse(strWinkel_b, out winkel_b) == false)) { GenerateErrorReport("Winkel Beta"); } }
        string strWinkel_y = this.txtGamma.Text; if (strWinkel_y == string.Empty) { i++; } else { if ((double.TryParse(strWinkel_y, out winkel_y) == false)) { GenerateErrorReport("Winkel Gamma"); } }

        //Height
        string strHoehe_a = this.txt_ha.Text; if (strHoehe_a == string.Empty) { i++; } else { if ((double.TryParse(strHoehe_a, out hoehe_a) == false)) { GenerateErrorReport("Höhe a"); } }
        string strHoehe_b = this.txt_hb.Text; if (strHoehe_b == string.Empty) { i++; } else { if ((double.TryParse(strHoehe_b, out hoehe_b) == false)) { GenerateErrorReport("Höhe b"); } }
        string strHoehe_c = this.txt_hc.Text; if (strHoehe_c == string.Empty) { i++; } else { if ((double.TryParse(strHoehe_c, out hoehe_c) == false)) { GenerateErrorReport("Höhe c"); } }

        //ErrorReport:
        if (ErrorMessage != null)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorAlert", "alert('Folgende Angaben sind fehlerhaft: " + ErrorMessage + "');", true);
            return;
        }

        //Logic
        //If more than 3 values....

        string AlertText;

        if (i < 6)
        {
            AlertText = "Es dürfen nur 3 Angaben gemacht werden!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorAlert", "alert('" + AlertText + "');", true);
            return;
        }
        if (i > 6)
        {
            AlertText = "Es müssen mindestens 3 Angaben gemacht werden!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorAlert", "alert('" + AlertText + "');", true);
            return;
        }
    }

    protected void Berechnen()
    {
        //Höhensatz

        if (seite_a != 0 && seite_b != 0 && seite_c != 0)
        {
            //Calculate missing angles

                //Winkel Gamma
                cos_y = (seite_a * seite_a) + (seite_b * seite_b) - (seite_c * seite_c); //Zähler berechnen
                cos_y = cos_y / (2 * seite_a * seite_b); //Durch Nenner teilen
                winkel_y = Math.Acos(cos_y); //Bogenradius berechnen
                winkel_y = winkel_y * 180 / Math.PI; //In Winkel umrechnen

                //Winkel Beta
                cos_b = (seite_c * seite_c) + (seite_a * seite_a) - (seite_b * seite_b); //Zähler berechnen
                cos_b = cos_b / (2 * seite_c * seite_a); //Durch Nenn teilen
                winkel_b = Math.Acos(cos_b); //Bogenradius berechnen
                winkel_b = winkel_b * 180 / Math.PI; //In Winkel umrechnen

                //Winkel Alpha
                double winkel_a = 180 - winkel_b - winkel_y;

                //Werte eintragen
                txtAlpha.Text = Convert.ToString(winkel_a);
                txtBeta.Text = Convert.ToString(winkel_b);
                txtGamma.Text = Convert.ToString(winkel_y);

            //Flächen berechnen

                //Mit Satz des Heron
                Heron heron = new Heron(seite_a, seite_b, seite_c);
                double FlaecheHeron = heron.Area;
                Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorAlert", "alert('" + FlaecheHeron + "');", true);     
        }
    }

The problem is, that there are so much possible combinations.
if (seite_a != 0 && seite_b != 0 && seite_c != 0), etc, etc….

  • 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-06-12T21:05:47+00:00Added an answer on June 12, 2026 at 9:05 pm

    You could write down all the rules you could possibly use to perform your computations. I guess you’d use angle sum, law of sines, law of cosines, and so on. Write each of these rules as a class, and create an instance for each possible labeling for each of these (i.e. whether you’re using the law of cosines to compute γ or β). You should end up with a list of objects, all sharing a common interface, which you can use to compute some values from some others. You could then iterate over this list to see which rules apply, and use them to compute additional values. Once the count of missing values reaches zero, you are done.

    If you iterate over all your rules without finding a rule to apply, then your set of possible rules isn’t complete enough. I believe that it would be a very good idea to write a unit test which tries out all 220 possible ways to fill in three out of twelve inputs, to make sure that you have a sufficient set of rules to handle all of them. Simply start with a complete set of 12 values, compute all three-element subsets, feed them into your application code and compare the results against the expected values, taking numerical errors into account.

    The above approach is neither optimized for performance nor for numeric stability. If either of these is an issue for you, a different approach might be better suited.

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

Sidebar

Related Questions

i have been programming for sometime but all of my programming books have not
I have Programming Erlang book already and I use http://www.erlang.org/ site. But I can't
So you don't have programming privileges on a SharePoint Server but you can use
I have been programming for ios and I need to get address. How can
I have started programming a game for the iphone and as all beginners I
I have taken Problem #12 from Project Euler as a programming exercise and to
I am new to C++ and have programming knowledge only in Java. Can anyone
I have some programming knowledge, I can write console applications in Python, Java, and
I run multiple webpages that I have programming in .net. I am looking at
I have this massive array of ints from 0-4 in this triangle. I am

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.