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;

@Test

public void testCase1() {

setSystemIn("3");

Q1.main(null);

assertEquals("Please enter a number: 2 ",

systemOut().getHistory());

}

@Test

public void testCase2() {

setSystemIn("20");

Q1.main(null);

assertEquals("Please enter a number: 2 3 5 7 11 13 17 19 ",

systemOut().getHistory());

}

@Test

public void testCase3() {

setSystemIn("100");

Q1.main(null);

assertEquals("Please enter a numbe: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 ",

systemOut().getHistory());

}

@Test

public void testCase4() {

assertEquals(true,

Q1.is_Prime(3));

}

@Test

public void testCase5() {

assertEquals(true,

Q1.is_Prime(89));

}

@Test

public void testCase6() {

assertEquals(false,

Q1.is_Prime(87));

}

}

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 which asks the user to enter an integer number. You should create a java method is Prime which takes an integer input and returns boolean. is Prime method returns true if given number is prime, otherwise it returns false. The program prints all the prime numbers which are less than that integer number. Hint: A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself. Example Please enter a number : 10 | Please enter a number : 45 SS?E In C D 5*

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

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago