Question

In entry level form Develop a C# console application that computes the hypotenuse of a right...

In entry level form

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 . . .

0 0
Add a comment Improve this question Transcribed image text
Answer #1

using System;

class MainClass {

public static void Main (string[] args) {

while(true){

Console.WriteLine("enter length of first side: ");

//reading number from user

double s1 = Convert.ToDouble(Console.ReadLine());

Console.WriteLine("enter length of second side: ");

double s2 = Convert.ToDouble(Console.ReadLine());

if(s1==0 && s2==0)

break;

// using formula c2=sqrt a2+b2

double s3=Math.Sqrt(Math.Pow(s1,2)+Math.Pow(s2,2));

Console.WriteLine("Third side: "+s3);

}

}

}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
In entry level form Develop a C# console application that computes the hypotenuse of a right...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • please help me debug this Create a GUI for an application that lets the user calculate...

    please help me debug this Create a GUI for an application that lets the user calculate the hypotenuse of a right triangle. Use the Pythagorean Theorem to calculate the length of the third side. The Pythagorean Theorem states that the square of the hypotenuse of a right-triangle is equal to the sum of the squares of the opposite sides: alidate the user input so that the user must enter a double value for side A and B of the triangle....

  • Please help me with these two problems. Thank you. Part A Create a console-based application that...

    Please help me with these two problems. Thank you. Part A Create a console-based application that prompts the user to enter the total price of the transaction as well as a sale or discount percentage, then returns the price of the transaction with the percentage discount applied. You should create at least one method that accepts and returns data. Part B Create a console-based application named MealPrice that computes the price of a meal at a pirate-themed restaurant owned by...

  • help im alittle lost my teacher posted all this its suppose to be in C++ language....

    help im alittle lost my teacher posted all this its suppose to be in C++ language. can yoh leave comments ans type the code thank you Write a C++ program that accepts the lengths of three sides (a,b,c) of a triangle as input from the user Validate the user input, so that sides a, b, c can only be POSITIVE. The program output should indicate whether or not the triangle is an Equilateral Triangle, a Right Triangle, Isosceles which is...

  • PLEASE READ AND CODE IN BASIC C++ CODE. ALSO, PLEASE CODE USING THIS DO WHILE LOOP...

    PLEASE READ AND CODE IN BASIC C++ CODE. ALSO, PLEASE CODE USING THIS DO WHILE LOOP AND FORMAT: #include <iostream> using namespace std; int main() { //variables here    do { // program here             }while (true);    } Objectives To learn to code, compile and run a program containing SELECTION structures Assignment Write an interactive C++.program to have a user input the length of three sides of a triangle. Allow the user to enter the sides...

  • Can anyone help me out with any of these please? Lab Day & Time: Physics 1080...

    Can anyone help me out with any of these please? Lab Day & Time: Physics 1080 Forces and Traction: Prelab 50 2 Part 1 100 1. You are standing outside your house and walk 100m north. You turn right and walk 50m east. Finally, you turn right again and walk 100m south. a. How far have you walked? b. How far are you from your starting point in the north/south direction? c. How far are you from your starting point...

  • Use only if else nested if else only otherwise your answer won't be entertained. Problem 1(b):...

    Use only if else nested if else only otherwise your answer won't be entertained. Problem 1(b): Write a program that gives remainder without using modulus operator and loops. The first number entered will be dividend and second number entered will be divisor. Sample input: 15 6 Sample output: Remainder is 3 In a right triangle, the square of the length of one side is equal to the sum of the squares of the length of the other two sides. Write...

  • URGENT HELP NEEDED: JQuery. PLEASE POST SCREEN SHOTS Task 1: Downloading jQuery Right-click the link to...

    URGENT HELP NEEDED: JQuery. PLEASE POST SCREEN SHOTS Task 1: Downloading jQuery Right-click the link to download the uncompressed latest version of jQuery Copy the jQuery.x.x.x.js file in the folder and specified as source file. Task 2: Download and install HTML-Kit 1. Navigate to htmlkit.com. 2. Click Download HTML-Kit 292. After it downloads, launch HKSetup.exe. Choose Full installation (the default) Uncheck Yes, download and install HTML-Kit Tools Trial. 6. Click Next>Finish. Task 3: Creating a Simple jQuery Application Launch HTML-Kit....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT