In BlueJ using Java, write a program that can input and display a person’s family tree. This project requires a GUI class that allows the user to input the members of the family tree and print the family tree.
public class FTree
{
private class Node
{
String value;
Node left, right;
Node(String val)
{
value = val;
left = null;
right = null;
}
Node(String val, Node lChild, Node rChild)
{
value = val;
left = lChild;
right = rChild;
}
}
private Node root = null;
public boolean root(String x)
{
if (root == null){
root = new Node(x);
return true;}
else
return false;
}
public boolean addLeft(String p, String x)
{
Node parent = locate(p);
if (root == null ){
return false;}
else if (parent != null && parent.left == null){
parent.left = new Node(x);
return true;}
else
return false;
}
public boolean addRight(String p, String x)
{
Node parent = locate(p);
if (root == null ){
return false;}
else if (parent != null && parent.right == null){
//Adds node
parent.right = new Node(x);
return true;}
else
return false;
}
public Node locate(String p)
{
return locate(p, root);
}
private Node locate(String p, Node familyTree)
{
Node result = null;
if (familyTree == null)
return null;
if (familyTree.value.equals(p))
return familyTree;
if (familyTree.left != null)
result = locate(p,familyTree.left);
if (result == null)
result = locate(p,familyTree.right);
return result;
}
}
In BlueJ using Java, write a program that can input and display a person’s family tree....
Write a program in Java that will accept input and display a person's family tree. This program needs to have a root person that branches off to parents and grandparents and be made so that you can add people.
Write a java program that demonstrates recursion. This program can be in a java GUI frame or as a console application. On this one it is up to you. (It would probably work better as a console program for this particular program.) The input for this program is a number of boxes. Ask the user for this with a textbox or a prompt on the command line. Demonstrate recursion with a function called LoadTruck() that takes a number of boxes...
We are using blueJ for my java class, if you can help me id
greatly appreciate it.
Create a new Java program called Flip. Write code that creates and populates an array of size 25 with random numbers between 1-50. Print the array. Print array in reverse.
Java Programming Using BLUEJ
Modify the Game Of War project so that the game can be played
until a user specifies quitting from the keyboard.
Hint: Add a Scanner object to the Driver class to read
user input and a loop to repeat the play method.
Driver-GameOfWar Class Edit Tools Options Driver × Compile Undo Cut Copy Paste Find... Close Source Code import java.util.Scanner; t A Driver to execute Game Of War program t@John Manz * @version (a version number or...
Write a JAVA program to display a “*” triangle and a half diamond of size n, where n is the input of the program. For example, when the user enters 4 as n’s value, the program should print the following shapes of “*”: A triangle of size 4: * *** ***** ******* A half diamond of size 4: * *** ***** ******* ***** *** * Extra Credit (+5) Print the following pattern instead. A triangle of size 4, using *:...
Write a java program that uses a loop to input, from the user not using gui, a collection of values that are the number of steps taken each day for a sequence of days and stores those amounts in an array. the array length should be 31, The user is not required to enter 31 values. the program determines and displays the largest number of steps for a single day, the smallest number of steps for a single day and...
Write a Java Program to allow a user to guess a person’s age until they get it correct. After each guess, the user must be told whether their guess was correct, too high or too low. Once the user enters the correct age, the program must display how many guesses it took the user to guess the correct age.
We use bluej for our JAVA program. If you can help id greatly
appreciate it.
Create a new Java program called Flip. Write code that creates and populates an array of size 25 with random numbers between 1-50. Print the array. Print array in reverse.
We are using blueJ for my java class, if you can help me id
greatly appreciate it.
Create a new Java project/class called ChangeUp. Create an empty int array of size 6. Create a method called populateArray that will pass an array, use random class to choose a random index and prompt the user to enter a value, store the value in the array. Create a method called printArray that prints the contents of the array using the for each...
We are using blueJ for my java class, if you can help me id
greatly appreciate it.
Create a new Java project/class called ChangeUp. Create an empty int array of size 6. Create a method called populateArray that will pass an array, use random class to choose a random index and prompt the user to enter a value, store the value in the array. Create a method called printArray that prints the contents of the array using the for each...