Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1: Consider the following specification for a program: The triangle program accepts three integers, a, b, and c, as input (we will assume that

Question 1:

Consider the following specification for a program:

The triangle program accepts three integers, a, b, and c, as input (we will assume that the inputs are of the correct type). These are taken to be sides of a triangle. The output of the program is the type of triangle determined by the three sides: Equilateral, Isosceles, Scalene, or NotATriangle.

The integers a, b, and c must satisfy the following conditions:

C1. 1 a 200

C2. 1 b 200

C3. 1 c 200

C4. a < b + c

C5. b < a + c

C6. c < a + b

If an input value fails any of conditions C1, C2, or C3, the program notes this with an output message, for example, Value of b is not in the range of permitted values. Otherwise, the output is the type of triangle determined by the three sides: Equilateral, Isosceles, Scalene, or NotATriangle, as follows:

  1. If all three sides are equal, the program output is Equilateral.
  2. If exactly one pair of sides is equal, the program output is Isosceles.
  3. If no pair of sides is equal, the program output is Scalene.
  4. If any of the conditions C4, C5, and C6 is not met, the program output is NotATriangle.

Define the equivalence classes and boundary values and develop a set of test cases to cover them. To show the test coverage, fill a table with the following columns:

Test Case Identifier

Input Values

Expected Outputs

Actual Outputs

Test Case Result (Pass/ Fail)

Valid Equivalence Classes and Bounds Covered

Invalid Equivalence Classes and Bounds Covered

a

b

c

You must test the program by executing the test cases. The program is provided as a Java class file (see Q1.class on Moodle). For example, the output of the following command:

java Q1 1 100 100

is

Isosceles

here use this code ------------------------------------------------

mport java.util.Scanner;

public class question1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int a=input.nextInt(); int b=input.nextInt(); int c=input.nextInt(); /* int a = Integer.decode(args[0]); int b = Integer.decode(args[1]); int c = Integer.decode(args[2]);*/ boolean c1 = 1 <= a & a <= 200; boolean c2 = 1 <= b & b <= 200; boolean c3 = 1 <= c & c <= 200; if (!c1) { System.out.println("Value of a is not in the range of permitted values."); }

if (!c2) { System.out.println("Value of b is not in the range of permitted values."); }

if (!c3) { System.out.println("Value of c is not in the range of permitted values."); }

if (c1 && c2 && c3) { boolean isATriangle; if (a < b + c & b < a + c & c < a + b) { isATriangle = true; } else { isATriangle = false; }

if (isATriangle) { if (a == b & b == c) { System.out.println("Equilateral"); } else if (a != b & a != c & b != c) { System.out.println("Scalene"); } else { System.out.println("Isosceles"); } } else { System.out.println("NotATriangle"); }

} } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

Students also viewed these Databases questions

Question

In the citation Reg. 1.247-3, what do the 1 and the 247 indicate?

Answered: 1 week ago