You are designing the tests for a genealogy search program. Design equivalence c
ID: 3749747 • Letter: Y
Question
You are designing the tests for a genealogy search program. Design equivalence class tests and boundary tests to cover all aspects of this program List the boundaries you are testing, as well as the equivalence classes you are testing, and list the test cases for each. Do not forget to list the expected results. Grading: This assignment will be graded based on finding all the boundary conditions and equivalence classes. There are more than meet the eye. However, beware of redundant test cases - after all, testing time is always limited. The user can input the following information, and then do a query. The program will either return the results of the query, or will return a message saying "invalid query." A valid query can return either a set of names (don't worry how many), or a message saying "no persons found matching your query." 1. Surname, up to 20 characters. Longer names are truncated.
Explanation / Answer
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
public class CheggArray3 {
public static void main(String[] args) throws ParseException {
Scanner in=new Scanner(System.in);
System.out.println("Enter Name:");
String name=in.nextLine();
//If name greater than 20 character then truncate it
if(name.length()>20)
name=name.substring(0,19);
System.out.println("Enter Surname");
String surname=in.nextLine();
//If surname greater than 20 character then truncate it
if(surname.length()>20)
surname=surname.substring(0,19);
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
//Enter marriage data
System.out.println("Please at least one date");
System.out.println("Please enter date in format dd/mm/yyyy");
System.out.println("Please enter birthday");
Date bd= formatter.parse(in.nextLine());
//City and country optional
System.out.println("You may enter city and country of birth");
String bddata=in.nextLine();
System.out.println("If you want to enter death data press 1");
int a1=in.nextInt();
Date deathd=null;
String dddata=null;
in.nextLine();
//Enter marriage data
if(a1==1){
System.out.println("Please enter Death day");
deathd=formatter.parse(in.nextLine());
//City and country optional
System.out.println("You may enter city and country of Death");
dddata=in.nextLine();
}
System.out.println("If you want to enter marriage data press 1");
a1=in.nextInt();
in.nextLine();
Date bmarriaged=null;
String mddata=null;
if(a1==1){
//Enter marriage data
System.out.println("Please enter Marriage Day");
bmarriaged=formatter.parse(in.nextLine());
//City and country optional
System.out.println("You may enter city and country of mirrage");
mddata=in.nextLine();
}
System.out.println("Name :"+name+" "+surname);
System.out.println("Birth Data :"+bd.toString()+" "+bddata);
if(deathd!=null)
System.out.println("Birth Data :"+deathd.toString()+" "+dddata);
if(bmarriaged!=null)
System.out.println("Birth Data :"+bmarriaged.toString()+" "+mddata);
}
}
Output:
Enter Name:
Tony
Enter Surname
Stark
Please at least one date
Please enter date in format dd/mm/yyyy
Please enter birthday
01/11/1995
You may enter city and country of birth
Moon
If you want to enter death data press 1
5
If you want to enter marriage data press 1
1
Please enter Marriage Day
20/02/2020
You may enter city and country of mirrage
LosAngles
Name :Tony Stark
Birth Data :Wed Nov 01 00:00:00 IST 1995 Moon
Birth Data :Thu Feb 20 00:00:00 IST 2020 LosAngles
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.