UseMath
Write a program called UseMath. It should contain a class called UseMath that contains the method main. The program should ask for a number from the user and then print the information shown in the examples below. Look at the examples below and write your program so it produces the same input/output.
Examples
(the input from the user is in bold face) % java UseMath enter a number: 0 the square root of 0.0 is: 0.0 rounded to the nearest integer: 0 the value of PI is: 3.141592653589793 the value of PI plus your number is: 3.141592653589793 rounded to the nearest integer: 3 the value of E plus your number is: 2.718281828459045 the absolute value of your number is: 0.0 % java UseMath enter a number: 1 the square root of 1.0 is: 1.0 rounded to the nearest integer: 1 the value of PI is: 3.141592653589793 the value of PI plus your number is: 4.141592653589793 rounded to the nearest integer: 4 the value of E plus your number is: 3.718281828459045 the absolute value of your number is: 1.0 % java UseMath enter a number: -1 the square root of -1.0 is: NaN rounded to the nearest integer: 0 the value of PI is: 3.141592653589793 the value of PI plus your number is: 2.141592653589793 rounded to the nearest integer: 2 the value of E plus your number is: 1.718281828459045 the absolute value of your number is: 1.0 % java UseMath enter a number: .5 the square root of 0.5 is: 0.7071067811865476 rounded to the nearest integer: 1 the value of PI is: 3.141592653589793 the value of PI plus your number is: 3.641592653589793 rounded to the nearest integer: 4 the value of E plus your number is: 3.218281828459045 the absolute value of your number is: 0.5 % java UseMath enter a number: .1 the square root of 0.1 is: 0.31622776601683794 rounded to the nearest integer: 0 the value of PI is: 3.141592653589793 the value of PI plus your number is: 3.241592653589793 rounded to the nearest integer: 3 the value of E plus your number is: 2.818281828459045 the absolute value of your number is: 0.1 % java UseMath enter a number: 10 the square root of 10.0 is: 3.1622776601683795 rounded to the nearest integer: 3 the value of PI is: 3.141592653589793 the value of PI plus your number is: 13.141592653589793 rounded to the nearest integer: 13 the value of E plus your number is: 12.718281828459045 the absolute value of your number is: 10.0 %
In: Computer Science
This is a java program
I am trying to figure out how to add a couple methods to a program I am working on.
I need to be able to:
1. Remove elements from a binary tree
2. Print them in breadth first order
Any help would appreciated.
//start BinaryTree class
/**
*
* @author Reilly
* @param <E>
*/
public class BinaryTree {
TreeNode root = null;
TreeNode current, parent;
private int size = 0, counter = 0;
public int getSize() {
return this.size;
}
public boolean insert(int el) {
current = root;
if (current == null) {
root = new TreeNode(el);
} else {
parent = null;
current = root;
while (current != null) {
if (el < current.element) {
parent = current;
current = current.left;
} else if (el > current.element) {
parent = current;
current = current.right;
} else {
return false;
}
}
if (el < parent.element) {
parent.left = new TreeNode(el);
}
if (el > parent.element) {
parent.right = new TreeNode(el);
}
}
this.size++;
return true;
}
public boolean search(int el) {
current = root;
while (current != null) {
if (el < current.element) {
current = current.left;
} else if (el > current.element) {
current = current.right;
} else {
return true;
}
}
return false;
}
public void inorder() {
inorder(root);
System.out.print("\n");
}
public void inorder(TreeNode curRoot) {
if (curRoot == null) {
return;
}
inorder(curRoot.left);
System.out.print(curRoot.element + " ");
inorder(curRoot.right);
}
public void postorder() {
postorder(root);
System.out.print("\n");
}
public void postorder(TreeNode curRoot) {
if (curRoot == null) {
return;
}
postorder(curRoot.left);
postorder(curRoot.right);
System.out.print(curRoot.element + " ");
}
public void getNumberOfLeaves() {
if (oddOrEven(getNumberOfLeaves(root))) {
System.out.println("Even");
} else {
System.out.println("Odd");
}
}
int getNumberOfLeaves(TreeNode curRoot) {
if (curRoot == null) {
return 0;
}
if (curRoot.left == null && curRoot.right == null) {
return 1;
} else {
return getNumberOfLeaves(curRoot.left) +
getNumberOfLeaves(curRoot.right);
}
}
public boolean oddOrEven(int x) {
return (x % 2) == 0;
}
}
//start Driver class
public class Driver {
public static void main(String[] args) {
BinaryTree tree = new BinaryTree();
tree.insert(10);
tree.insert(5);
tree.insert(15);
tree.insert(6);
tree.insert(4);
tree.insert(20);
tree.inorder();
tree.getNumberOfLeaves();
tree.inorder();
}
}
//start TreeNode class
public class TreeNode {
int element;
TreeNode left;
TreeNode right;
public TreeNode(int el)
{
this.element = el;
}
}
In: Computer Science
In: Nursing
The five key activities in an object-oriented design process are:
a. Define the context and modes of use of the system;
b. Design the system architecture;
c. Identify the principal system objects;
d. Develop design models;
e. Specify object interfaces.
Please give me an explanation and example in detail for the five activities.
In: Computer Science
There are THREE common ISO certificates for surgical masks. What are they? Explain.
In: Operations Management
do you think biological processes influence physical and mental growth across a lifetime or do you feel that our environmental surroundings affect this change
In: Psychology
Q.1 A social psychologist is interested in whether the amount of couple photos (photos featuring the couple together) people post on social media would vary across relationship stages. He administered a questionnaire to a group of couples (one questionnaire for each couple) at the anniversaries of their first year, second year, third year, and fourth year of dating. The questionnaire asked about the total amount of couple photos they posted in social media during the past year. Below are the data, with a higher number denoting more couple photos posted:
first year | second year | third year | fourth year | |
student 1 | 200 | 190 | 150 | 100 |
student 2 | 250 | 200 | 145 | 120 |
student 3 | 190 | 220 | 160 | 105 |
student 4 | 170 | 180 | 165 | 140 |
a. What are the independent variable and dependent variable of this study?
b. Write down the omnibus null hypothesis and the alternative hypothesis for the overall effect of the independent variable.
c. Conduct a proper statistical test by hand calculation to test the omnibus hypothesis with 5% as the level of significance (α). (For this exercise, the data assumptions of your chosen statistical test can be taken as reasonably met.) Show your calculation formulae and steps. In case you decide to conduct an ANOVA, you are not required to conduct any post-hoc comparisons. Decide whether to reject the null hypothesis or not and state the basis of your decision.
d. Calculate the effect size in terms of eta-squared and omega-squared.
In: Math
If you are a manager of a restaurant, you are required to apply Total Quality Management philosophy to improve the hygiene quality level. Design FIVE practices by applying the concepts of Universal points of Total Quality Management.
In: Operations Management
At the beach, some waves with wavelength of 100 m propagate towards the shore at a speed of 12.5 m/s. (c) Does the engine sound higher- or lower-pitched to someone standing on the shore, compared with the experience of people on the boat?
(a) Calculate the frequency that boat anchored near shore bobs up and down as the waves roll in.
(b) At what frequency the boat would bob up and down with if it were headed away from the shore at a speed of 4.8 m/s?
(c) At what frequency the boat would bob up and down with if it were headed toward the shore at a speed of 4.8 m/s?
In: Physics
The language is C++
Below are a list of sequences of numbers. Your job is to program each sequence with any loop of your preference (while, for, do/while). I want the code to output the sequence provided and the next number in the sequence (you can output more but there is 1 sequence that may only have 1 number after).. Please order and notate each sequence in your output –. The output should also be horizontal like that shown below (if you output it vertically it will be -10pts). Each sequence should be programed with only 1 loop and optionally 1 selection statement. Hint: a selection statement may be used for the last 3 problems.
Series 1:
15, 14, 13, 12, 11, ...
Series 2:
1, 2, 5, 14, 41, ...
Series 3:
2, 3, 5, 8, 12, 17, ...
Series 4:
15, 13, 11, 9, 7, ...
Series 5:
71, 142, 283, 564, 1125, 2246, 4487, 8968, ...
Series 6:
10, 5, 1, -2, -4, -5, -5, -4, -2, ...
Series 7:
0, 1, 3, 7, 15, 31, 63, ...
Series 8:
0, 1, 4, 13, 40, 121, ...
Series 9:
15, 29, 56, 108, 208, 400…
series 10: (finite)
0, 1, 3, 6, 10, 10, 11, 13, 16, 16, 17, 19, 19, ...
series 11:
7, 9, 14, 20, 27, 33, 42, 52, 63, 73, 86, ...
Series 12:
13, -21, 34, -55, 89 ...
Series 13:
0, 1, 4, 12, 32, 80, 192, ...
In: Computer Science
what are the objective of incentive plan? Explain the conditions necessary for successful operation of incentive scheme?
In: Operations Management
Calculate the CPR and SMM using the 350% PSA schedule for months t=1 through t=30. Display your results in a table below with four columns labeled, from left to right, t, PSA, CPR, SMM.
In: Finance
Generate all permutations of {3, 8, 2} by the Johnson-Trotter algorithm. Show the steps.
In: Computer Science
Problem 1 The United States Federal Income tax for taxes due July 15, 2020 is available at this link: https://www.bankrate.com/finance/taxes/tax-brackets.aspx The four tax filing categories are: 0 - single filer, 2 - head of household, 3 - married filing jointly or qualifying widow, and 4 - married filing seperately. Write a Java program that prompts the user to enter the name, filing status, and annual income. The program returns the federal income tax due. (10 Points) A sample run should look like: Enter your name: Jane Doe Enter your 2019 federal income: 48,000 Enter your filing status: single Jane Doe, the federal income tax for an annual salary of 48,000 for a single filer is $4,800. Draw a UML diagram for the class. You may use Astah tool. (5 points). Submit both the java code and UML diagram. *
In: Computer Science
This is a beginner C++ class
Your program will be creating 10 library books. Each library book will have a title, author and publishing year. Each library book will be stored as a structure and your program will have an array of library books (an array of structures).
After creating the struct, the next task is to create a new separate array for book genres.
You will create this corresponding array of book genres: Mystery, Romance, Fantasy, Technology, Children, etc. If the first element of the structure is storing information about a book titled : "More about Paddington", then the corresponding first element of array book genre would indicate 'Children'.
You should only use structure and array. You are not allowed to use vectors.
The user of your program should be able to select what they want to do from a menu of the following things and your program needs to do what the menu selection indicates:
* Print the entire list of library books (including the title, author, publishing year and book genre)
* Display a count of how many books exist per genre
* Find and display all books where the publishing year is greater than the year user put in
* Print the titles of the books where the Genre may be indicated by a 'C' for Children, & 'M' for Mystery
In: Computer Science