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 Q3Test extends

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 Q3Test extends student.TestCase {

static JUnitCore junitCore;

static Class> testClasses;

@Test

public void testCase1() {

setSystemIn("merhaba");

Q3.main(null);

assertEquals("Please enter a word: The resulting word is MerXabA ",

systemOut().getHistory());

}

@Test

public void testCase2() {

setSystemIn("istanbul");

Q3.main(null);

assertEquals("Please enter a word: The resulting word is IstaXbuL ",

systemOut().getHistory());

}

}

Question 3. Write your solution in file Q3.java. Use Q3Test.java to test your solution. Write a Java program which asks the user to enter a String. The program changes the middle character of the word into X character and turns the first and last characters of the word into uppercase letters P.S. You need to use charAt method of String Example Please enter a word: merhaba The resulting word is MerXabA Please enter a word: istanbul The resulting word is IstaXbuL

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

Students also viewed these Databases questions