{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# basicproofs - /Statement 2/if x y z satisfy the triangle...

This preview shows page 1. Sign up to view the full content.

public class basicproofs { //@ requires (x>0); //@ ensures (x>=1); public void demoproof(int x) { //For all integers x, if x > 0 then x >= 1 } //@ requires ((x+y)>z & (x+z)>y && (y+z)>x); public void proof1(int x, int y, int z) { //Statement 1: //if x, y, z satisfy the triangle inequalities then x, y, z are positive } //@ requires ((x+y)>z & (x+z)>y && (y+z)>x); //@ ensures (x > Math.abs(y-z) & y > Math.abs(x-z) && z > Math.abs(y-x)); public void proof2(int x, int y, int z) {
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: //Statement 2: //if x, y, z satisfy the triangle inequality then each side is //larger than the absolute difference of the other two sides //Hint: Use the Java function Math.abs() to compute absolute values } //@ requires (x > Math.abs(y-z) && y > Math.abs(x-z) && z > Math.abs(y-x)); //@ ensures ((x+y)>z && (x+z)>y && (y+z)>x); public void proof3(int x, int y, int z) { //Is the converse of Statement 2 true? Try and find out! } }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online