Posted on Leave a comment

Solution to PythagoreanTheorem – Assignment 2

[code lang=”java”]
/*
* File: PythagoreanTheorem.java
* Name:
* Section Leader:
* —————————–
* This file is the starter file for the PythagoreanTheorem problem.
*/

import acm.program.*;

public class PythagoreanTheorem extends ConsoleProgram {
public void run() {
println("Enter values to compute Pythagorean Theorem.");
int a = readInt("a: ");
int b = readInt("b: ");
double c = Math.sqrt((a*a)+(b*b));
println("c= "+c);

}
}
[/code]

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.