Question: (JAVA) How do I write a JUNIT test for this input output scenario? How do I test to see that if the user enters A

(JAVA)

How do I write a JUNIT test for this input output scenario? How do I test to see that if the user enters "A" I get a "You've found the treasure!" notification?

import java.util.Scanner;

public class test {

public void Sink() {

System.out.println("Okay Now Questions 2 for the Treasure ");

System.out.println("What grade will I get for this project?");

Scanner scanner = new Scanner(System.in);

String anwser = scanner.nextLine();

String secret = "A";

String secret2 = "A+";

String secret3 = "a";

String result1 = "You've Found The Treasure!";

String result2 = ":( Wrong Anwser Keep Playing";

if(anwser.equals(secret3) || anwser.equals(secret2) || anwser.equals(secret)) {

System.out.print(result1);

}else {

System.out.print(result2);

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!