Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You should do the assignment according to Q1Test in below, using student.TestCase, if you do correctly i will give %100 thumbs up. import java.io.IOException; import

image text in transcribed

You should do the assignment according to Q1Test in below, using student.TestCase, if you do correctly i will give %100 thumbs up.

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;

double s = 5;

double a = 2.5;

@Test

public void testCase1() {

setSystemIn("3", "2", "0");

Q1.main(null);

assertEquals("Enter a number: Enter a number: Enter a number: You have entered 2 numbers. Sum = " + s

+ " Average = " + a + " ", systemOut().getHistory());

}

double s1 = -6;

double a1 = -2;

@Test

public void testCase2() {

setSystemIn("-5", "-3", "2", "0");

Q1.main(null);

assertEquals(

"Enter a number: Enter a number: Enter a number: Enter a number: You have entered 3 numbers. Sum = "

+ s1 + " Average = " + a1 + " ",

systemOut().getHistory());

}

double i2 = 1.5;

@Test

public void testCase3() {

setSystemIn(i2 + "", "0");

Q1.main(null);

assertEquals("Enter a number: Enter a number: You have entered 1 numbers. Sum = " + i2 + " Average = " + i2

+ " ", systemOut().getHistory());

}

}

SUBMISSION RULES It is your own responsibility to make sure your submission is in the correct format. In case you fail to follow these steps, your worksheet will not be graded by the automatic system and your grade will be zero Question 1. Write your solution in file Q1.java. Use Q1Test.java to test your solution. Write a Java program using do-while loop that asks the user to continuously enter a number until the user enters 0. When the user enters 0, the program prints how many numbers user has entered, the sum of the entered numbers and their average Example Enter a number 2 Enter a number: 3 Enter a number 0 You have entered 2 numbers Sum-5.0 Average 2.5 Enter a number -5 Enter a number -3 Enter a number 2 Enter a number 0 You have entered 3 numbers Sum - -6.0 Average-2.0

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 Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions