In: Computer Science
Use your creativity to make a Novelty Name Generator of your choice, ie: Spooky Halloween Names, Christmas Elf Names, Anything that is school appropriate.
To create the novelty name you should use at least 2 associative arrays.
The page design is up to you. For example:
Hi,
I created java programs for all options which you wanted..you didint specify any language option so i choosed java for the implementation.
There are 3 option you will have while running the program
1. Display list of Student with their novelty name.
2. Add more students with theri novelty names
3. Search student by his name to see his/her novelty name.
4. Quit to quuit from the system(program).
I created one class called NoveltyName.java which will store name and novelty name of each studdent and then it will be added by a container or data structure called ArrayList for further more processing.
NoveltyName.java:
public class NoveltyName
{
private String stdName;
private String novName;
// DEfault constructor
NoveltyName(){
System.out.println("Default constructor");
}
NoveltyName(String stdName, String novName){
//System.out.println("arrgument constructor");
this.stdName = stdName;
this.novName = novName;
}
public String getStdName()
{
return stdName;
}
public String getNovName()
{
return novName;
}
@Override
public String toString()
{
return stdName + "\t\t\t" + novName;
}
}
TestNoveltyName.java:
Another class is main driver class where we wil get alot of option to get command from user.
import java.util.Scanner;
import java.util.ArrayList;
public class TestNoveltyNames
{
public static void main(String[] args)
{
// Array list to add all the students information in this class object
ArrayList<NoveltyName> list = new ArrayList<NoveltyName>();
String choice="";
// Added name of students and their novelty names
NoveltyName nnames1 = new NoveltyName("Arachna", "Spider Woman");
NoveltyName nnames2 = new NoveltyName("Banshee", "Screaming Spirit");
NoveltyName nnames3 = new NoveltyName("Barnabas", "Dark Shadows");
NoveltyName nnames4 = new NoveltyName("Beelzebub", "Devil");
NoveltyName nnames5 = new NoveltyName("James", "Legand");
list.add(nnames1); // added student object in array list
list.add(nnames2);
list.add(nnames3);
list.add(nnames4);
list.add(nnames5);
Scanner input = new Scanner(System.in);
while(true){
System.out.println("########## Please choose below options: #############\n");
//user can choose below options
System.out.println("1. To display students list their novelty names.");
System.out.println("2. To add student name with his novelty name.");
System.out.println("3. To search novelty name by student original name.");
System.out.println("4. Quit.");
choice = input.nextLine();
// by this we are displaying studdent information
if(choice.equals("1")){
System.out.println("Student Name: Novelty Name:\n");
for(NoveltyName nm : list){
System.out.println(nm);
}
}
// user can add more student wwith their novelty names
else if(choice.equals("2")){
while(true){
System.out.println("Please enter name of the student: ");
String name = input.nextLine();
System.out.println("Please enter novelty name of the student: ");
String novName = input.nextLine();
list.add(new NoveltyName(name, novName));
System.out.println("Name added succesfully.\n");
System.out.print("Do you want to add more names? press (y/n)? ");
choice = input.nextLine();
if(choice.equalsIgnoreCase("n"))
break;
}
}// else if end for 2
else if(choice.equals("3")){
//search student by his name
System.out.println("Please enter student original name? ");
choice = input.nextLine();
for(NoveltyName nm : list){
if(nm.getStdName().equalsIgnoreCase(choice)){
System.out.println(nm);
}
}
}
// quite from the system.
else {
System.out.println("Quit from the system.");
break;
}
} // outer while loop
}
}
Output: