Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the Test Class ; import java.io.IOException; import java.io.PrintWriter; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestWatcher; import org.junit.runner.Description; import org.junit.runner.JUnitCore; import org.junit.runner.Result; public class Q1Test

image text in transcribed

This is the Test Class ;

import java.io.IOException;

import java.io.PrintWriter;

import org.junit.Rule;

import org.junit.Test;

import org.junit.rules.TestWatcher;

import org.junit.runner.Description;

import org.junit.runner.JUnitCore;

import org.junit.runner.Result;

public class Q1Test extends student.TestCase

{

static JUnitCore junitCore;

static Class> testClasses;

@Test

public void testCase1() {

setSystemIn("6", "4","7");

Q1.main(null);

assertEquals("Please enter 3 integers: Area of the triangle is 11.98.",

systemOut().getHistory());

}

@Test

public void testCase2() {

setSystemIn("4", "5", "8");

Q1.main(null);

assertEquals("Please enter 3 integers: Area of the triangle is 8.18.",

systemOut().getHistory());

}

@Test

public void testCase3() {

setSystemIn("9", "12", "8");

Q1.main(null);

assertEquals("Please enter 3 integers: Area of the triangle is 36.00.",

systemOut().getHistory());

}

}

Question 1. Write your solution in file Q1.java. Use Q1Test.java to test your solution. Write a Java program, which asks the user to enter three integer numbers a,b and c that are three sides of a triangle, and calculates the area of the triangle by using Heron's formula. Heron's Formula a +b+c Area = Vs(s-a)(s-b)(s-c) Example Please enter 3 integers: 6 7 Area of the triangle is 11.98 Please enter 3 integers 12 Area of the triangle is 36

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

Step: 3

blur-text-image

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

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions