Purchase Solution

C# Application for calculating a hypotenuse

Not what you're looking for?

Ask Custom Question

Develop a C# console application that computes the hypotenuse of a right triangle. The computation of the hypotenuse of a right triangle is based on the Pythagorean Theorem: c2 = a2 + b2 and the hypotenuse, c ("long side") of the triangle can be computed with the formula the hypotenuse is equal to the square root of the side a squared plus side b squared.
The application should take as many side pairs inputs as the user desires and calculate each until the user enters a zero for both side one and side two (sentinel loop). You should use at least two (2) Math class methods.
The output should look something like this:
enter length of first side: 3

enter length of second side: 4

The hypotenuse is 5

enter length of first side: 3.44

enter length of second side: 4.88

The hypotenuse is 5.97059461025449

enter length of first side: 10.55

enter length of second side: 33.0

The hypotenuse is 34.6453820876607

enter length of first side: 0

enter length of second side: 0

Press any key to continue . . .
Note in the first example with the entries of 3 and 4 that the hypotenuse is computed as 5. If you are not getting that answer (The hypotenuse is 5) with entries of 3 and 4 respectively, then you are not taking the inputs and converting them correctly. Remember that a ReadLine brings in characters but there are differences in how the conversion methods for character and string values work. There is another way to convert a string number input to a numeric value type. You may have to do some research to come up with the right conversion method. Also note that type double values are used.
Name the .cs file Assignment_6_yourlastname and submit it to the link below.
Submit only the .cs file with your code in it.

Purchase this Solution

Solution Summary

The solution assists with calculating a hypotenuse using a C# application.

Solution Preview

See the attached file.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

/*
Develop a C# console application that computes the hypotenuse of a right triangle. The computation of the
* hypotenuse of a right triangle is based on the Pythagorean Theorem: c2 = a2 + b2 and the hypotenuse, c ("long side")
* of the triangle can be computed with the formula the hypotenuse is equal to the square root of the side
* a squared plus side b squared.
The application should take as many side pairs inputs as the user desires and calculate each until the user
* enters a zero for both side one and side two (sentinel loop). You should use at least two (2) Math class methods.
The output should look something like this:
enter length of first side: 3

enter length of second side: ...

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Basic Networking Questions

This quiz consists of some basic networking questions.

Javscript Basics

Quiz on basics of javascript programming language.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.