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

  • Home
  • SEARCH
  • 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 8589813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:08:47+00:00 2026-06-11T23:08:47+00:00

I have created a program that wehn the calculate button is pressed, an average

  • 0

I have created a program that wehn the calculate button is pressed, an average speed will be calculated using the total distance travled and the total hours traveled, and that will be multiplied by the time to get from NY city to MIAMI to get the distance from NY city to MIAMI. After button click Label1 will report the speed, the time and distance and Clear_textBox() will clear all textbox fields. The problem is that I am not getting any results back but errors.

Can some one give me guidance in changes to be made in my code?

the functions I am receiving an error Display_Results and property private double get_Time

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



    private double Calculate_Velocity()
    {
        //Calculate Velocity
        int startingMileageBox;
        startingMileageBox = Convert.ToInt32(textBox1.Text);

        int endingMileageBox;
        endingMileageBox = Convert.ToInt32(textBox2.Text);

        double time = Get_Time(); //assuming you have set up GetTime()
        double distance = endingMileageBox - startingMileageBox;
        return distance / time; 
    }

   public double Get_Time()
    {
        //Get Time
        return get_Time;
    }

    private double Calculate_Distance(double velocity, double time)
    {
        //Calculate Distance
        return velocity * time;
    }

    private void Display_Results(double velocity, double time, double distance)
    {
        //Display Results
        label1.Text = "Velocity = " + velocity.ToString() + " time= " + time.ToString() + " Distance = " + distance.ToString();
    }

    private void Clear_Textboxes()
    {
        //Clear textboxes
        textBox1.Clear();
        textBox2.Clear();
        textBox3.Clear();
        textBox4.Clear();
    }



    // Property to GetTime
    private double get_Time
    {


        get
        {



            // variable to hold time
            double time = double.MinValue;

            // Safely parse the text into a double
            if (double.TryParse(textBox3.Text, out time))
            {
                return time;
            }

            // Could just as easily return time here   
            return double.MinValue;
        }
        set
        {
            // Set tbTime
            textBox3.Text = value.ToString();
        }
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void button2_Click(object sender, EventArgs e)
    {
        Close(); 
    }

    private void button1_Click(object sender, EventArgs e)
    {
        double v = Calculate_Velocity();
        double t = Get_Time();

        double d = Calculate_Distance(v, t);
        Display_Results(v, t, d);

        Clear_Textboxes();

    }
}

}

Form

enter image description here

  • 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-11T23:08:48+00:00Added an answer on June 11, 2026 at 11:08 pm

    I think Error is in this function

    private double Display_Results(double velocity, double time, double distance)
                {
                    //Display Results
                    label1.Text = time + velocity + distance;
                }
    

    please convert time +velocity+distance value in string format.

    Try following

    private double Display_Results(double velocity, double time, double distance)
                {
                    //Display Results
                    double v=-velocity;
                    double t=-time;
                    double d=-distance;
    
                    label1.Text = (t + v + d).ToString();
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a program in Java using eclipse that contains a couple of
I created a program that will use a dynamic array by using pointer to
I have created a very simple program that uses recursion. I'm using the g++
I am using vb.net 2010 and I have created a program that uses sockets
I have Created one Program Using Lwuit,Midlet. In that program I am showing Dialog
I have created a non-form c# program that uses the NotifyIcon class. The text
For a school assignment I have to create a C++ program that will create
I have created a program that write video stream to a named pipe on
I have created a program that decrypts whats stored in a export file from
I have created a program that opens image files. How can I make my

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.