Questions
JAVA 1 PROGRAMMING QUESTION In this program you will be writing a class that will contain...

JAVA 1 PROGRAMMING QUESTION

In this program you will be writing a class that will contain some methods. These will be regular methods (not static methods), so the class will have to be instantiated in order to use them.
The class containing the main method will be provided and you will write the required methods and run the supplied class in order to test those methods.

? Specifications

  • There are two separate files in this program. The class containing the main method is supplied, and you will write a new class containing the methods you will write.

? The code for the testing class is given below. In order to test the code you write, you will need to rename this file as you have all of your program files, as outlined above. You will need to change the calls to the methods to reflect the class where your methods are located. Do not modify the logic in this file to make it fit your methods. Part of this problem is to meet the specifications of the test program.

  • Name the file (and class) you will create to hold the methods, MethodPractice (with the addition of your name data as above). This is the file that will have all of the methods other than the main method.

The Methods to Write

  • In the file called MethodPractice you will write the following methods:
    • displayLine()

      • This method will not accept arguments nor will it return any values.
      • You may use the illustrated “Basic void Method” up above.
      • This method simply displays a line by using: System.out.println("--------------------");
      • Make sure your method displays 20 dashes.
    • displayMessage()

      • This method will accept a String as an argument, but will not return a value.
      • This method will accept a String message and simply display that exact message on the screen.
    • sumNumbers()

      • This method will accept two integers as arguments.
      • This method will add those two integers together and return the sum.
    • isGreater()

      • This method will accept two integers as arguments.
      • This method will use if and else to test the two numbers to see if the first one is greater than or equal to the second.
      • If the first number is greater than or equal to the second, the method will return a boolean true. If the first number is not greater than or equal to the second number, then the method will return a boolean false.
      • This method could use two return statements. However, use only one return statement at the end of the method. You can accomplish this by setting a variable to one boolean state of true or false, and then returning that variable.
    • setBulb()

      • This method will accept a boolean argument, but will not return a value.
      • Based on a received boolean value, this method will use if and else to display a message of either “The bulb is now on.,” or “The bulb is now off.”

The Instance Variables

? Make all instance variables in the MethodPractice class private.

  • There are instance variables at the beginning of the MethodsPractice class. You may change those, but you will need to be consistent with the method calling from the main method in the MethodTest class.

The MethodTest.java Class

? Be sure to rename this file as you do all of your files, as outlined above, and upload this file along with the MethodPractice file. You will also need to modify the method calls to match your class name for the MethodPractice class.

  • Below is the class by which your methods will be tested. It contains the main method with calls to each of the methods you are will write in the MethodPractice class. Use this class to test your methods.
  • Remember to make the necessary modifications mentioned above.

In: Computer Science

Write the following classes: Class Entry: 1. Implement the class Entry that has a name (String),...

Write the following classes: Class Entry: 1. Implement the class Entry that has a name (String), phoneNumber (String), and address (String). 2. Implement the initialization constructor . 3. Implement the setters and getters for all attributes. 4. Implement the toString() method to display all attributes. 5. Implement the equals (Entry other) to determine if two entries are equal to each other. Two entries are considered equal if they have the same name, phoneNumber, and address. 6. Implement the compareTo (Entry other) method that returns 0 if the two entries have the same number, -1 if this.number is smaller than other.number, and + 1 if this.number is > other.number Class PhoneBook 1. Implement the class PhoneBook that has a city (String), type (String), entryList (an Array of Entry). Assume the array size = 10 2. Implement the constructors to initialize the city and type. 3. Implement the method addEntryToPhoneBook(Entry e) that adds an entry to the phone book. 4. Implement the method toString() that displays all attributes and all enties information of the phone book. 5. Implement the method displayAll() that displays all entries in the phone book. 6. Implement the method checkEntryByNumber(String number) that takes a number and returns the entry with that number if it exists. 7. Implement the method checkEntrisByName(String name) that takes a name, and returns an array of the entries that start with this name or letters. 8. Implement the method removeEntryFromPhoneBook (String number) that removes an entry from the array of entires in the phone book. Class TestPhoneBook 1. Create a phone book and initialize its attributes. 2. Add 5 entries to the phone book list using the method addEntryToPhoneBook() 3. Display all entries in the phone book. 4. Display the entry information for a given phone number if it exists. Give the appropriate message if it does not exist. 5. Display all entries starting with the letters "Abd" 6. Remove a specific entry from the phone book. Display the proper message if it was removed , or if it did not exist. 7. Sort and display the entries of the phone book (Bonus). Java NetBeans.

In: Computer Science

write mips assembly mips assembly (x+a) (bx^2+cx+d) using the pesedo- code with loop ,program should claclute...

write mips assembly

mips assembly (x+a) (bx^2+cx+d) using the pesedo- code with loop ,program should claclute six T[i] and display aproper message about roots .the the program should store all T[i] as memory array


a = [1, 1, 1, 1, 1, 1];
b = [1, 2, 4, 8, 16, 32];
c = [-6, -4, -2, 2, 4, 6];
d = [-1, -3, -5, -7, -9, -11];

for (i=0 ; i<=6; i++) {
T[i] =-4 *b [i] * d[i] +c[i] * c[i];
if (T[i] <0)
display "tow roots are imaginary";
else

display "tow roots are real ";
}

In: Computer Science

In Java We define BigNumber a number consisting of 0<N<21 elements.It can be negative in which...

In Java

We define BigNumber a number consisting of 0<N<21 elements.It can be negative in which case it will have a minus sign in front. Without modifying main method complete the methods add, subtract and reverse. Hints: class java.math.BigInteger would be very useful. For reverse method number== new StringBuffer(number).reverse().toString(); can be used however when you reverse a negative number the negative sign should stay in front. Thanks.

public class MD3 {

public static void main(String[] args)
{
BigNumber BigNumber1 = new BigNumber(args[0]);
BigNumber BigNumber2 = new BigNumber(args[1]);

BigNumber1.add(BigNumber2);
BigNumber1.display();
BigNumber1.reverse();
BigNumber1.display();

BigNumber2.subtract(BigNumber1);
BigNumber2.display();
BigNumber2.reverse();
BigNumber2.display();
}

class BigNumber {

private String number;
  
BigNumber(String str) { number = str; }

public void add(BigNumber sk) { /* ... */ }

public void subtract(BigNumber sk) { /* ... */ }
  
public void reverse() { /* ... */ }


  


  
public void display() {System.out.println(number);}
}
}

In: Computer Science

write java program that prompt the user to enter two numbers .the program display all numbers...

write java program that prompt the user to enter two numbers .the program display all numbers between that are divisible by 7 and 8 ( the program should swap the numbers in case the secone number id lower than first one please enter two integer number : 900 199 Swapping the numbers 224 280 336 392 448 504 560 616 672 728 784 840 896 i need it eclipse

In: Computer Science

write java program that prompt the user to enter two numbers .the program display all numbers...

write java program that prompt the user to enter two numbers .the program display all numbers between that are divisible by 7 and 8 ( the program should swap the numbers in case the secone number id lower than first one

please enter two integer number : 900 199  

Swapping the numbers

224 280 336 392 448 504 560 616 672 728 784 840 896

i need it eclipse

In: Computer Science

Write a C Program to finish the following requirements: Convert a double number to its hexadecimal...

Write a C Program to finish the following requirements: Convert a double number to its hexadecimal form

1. The double number x is located between 0 and 1000(0<=x<=1000),e.g.678.345

2.The double number with the hexadecimal form contains 6 significant digits. e.g." 5D.32FA45".

3.The double number with the hexadecimal form is represented by a string(or a character array), e.g."5D.32FA45".

Please write as simple as possible because I am a freshman in C! And please give me some clues!

Thanks!

In: Computer Science

Can someone fill in the blanks? using namespace std; double approxPi; // define the signal handler...

Can someone fill in the blanks?

using namespace std;

double approxPi;

// define the signal handler function
______
______
______
______
______

int main(int argc, char* argv[])
{
pid_t childPid;
double inside = 0;
double total = 0;
double oldPi = 0.0;
switch (childPid = fork()) { // fork the process
case -1:
cerr << "forking error";
exit(0);
case 0: // child process
// register SIGUSR1 handler
______
______
______

while (1) {
// calculate the approximate value of pi using the Monte Carlo method
for (int i = 0; i < 10000; ++i) {
double x = (double)rand() / RAND_MAX;
double y = (double)rand() / RAND_MAX;
if (x * x + y * y <= 1) {
inside++;
}
total++;
}
approxPi = 4.0 * inside / total;
}
default: // parent process
sleep(5);
______; // send the SIGUSR1 signal to the child
}
return 0;
}

In: Computer Science

Using a programming language of your choice, write a complete and fully functional program that uses...

  1. Using a programming language of your choice, write a complete and fully functional program that uses reference and pointer types to swap two double precision floating-point numbers. The two numbers are read in by the program’s user. Use a proper prompt for each number.
    1. Use one function that uses formal parameter reference types to swap the two numbers
    2. Use another function that uses formal parameter pointer types to swap the two numbers.
    3. In the main or driver function, call these two functions with the actual arguments received from the program’s user
    4. Display immediately the result of the swapping after each function call in the calling function (the main function or the driver) before the next function call to see whether the numbers are swappe Use a proper display message.

In: Computer Science

a. Design a binary-to-octal converter. b. Design a logic circuit by which the following arithmetic expression...

a. Design a binary-to-octal converter.
b. Design a logic circuit by which the following arithmetic expression can be calculated and show how X = 9 - 5
c. Write a short note on the data distributor circuit.

In: Computer Science

You plan to visit your dentist for an emergency. You will be required to follow a...

You plan to visit your dentist for an emergency. You will be required to follow a specific process before you can see your dentist. Write an algorithm and draw a flowchart for this problem.

In: Computer Science

FOR SAGE PYTHON Koch snowflake: The Koch snowflake can be constructed by starting with an equilateral...

FOR SAGE PYTHON

Koch snowflake: The Koch snowflake can be constructed by starting with an equilateral triangle, then recursively altering each line segment as follows: Step 1: divide the line segment into three segments of equal length. Step 2: draw an equilateral triangle that has the middle segment from step 1 as its base and points outward. Step 3: remove the line segment that is the base of the triangle from step 2. After one iteration of this process, the resulting shape is the outline of a hexagram. The Koch snowflake is formed by repeating this process over and over again (in principle, infinitely many times, but in practice we will stop after a certain number of iterations). Your goal is to write a program which draws the Koch snowflake, following these instructions:

(a) Don’t attempt to draw any lines yet, you should do that only at the very end. Instead, you should create a list of all vertices (points) which you want to connect in the end.

(b) Write a function, called koch_bump(), which takes as input two tuples (the coordinates of two points P = (x1, y1) and Q = (x2, y2)), and which returns a list of 4 tuples, starting with P and followed by the three points between P and Q which form the ”bump” pointing outwards from the line segment. Hint: Linear Algebra (vector geometry) can make this a lot easier, but you can also figure out the coordinates of the needed points using basic high school geometry

(c) Write a function, called koch_iteration(), which takes as input a list of tuples (think of these as the vertices of the equilateral triangle you start with), and which returns a new list of tuples which contains all points after applying the subdivision process exactly once. To do this, go through the given list of points, and apply the function koch_bump() to each two adjacent ones (don’t forget to also apply it to the last and first points in the list): For example, if the list contains the points A, B, C, you should call koch_bump() on the pairs (A, B), (B, C), and (C, A) — but you should write the function so that it can deal with an arbitrary number of points in the list.

(d) Write a function, called koch_snowflake(), which takes as input a list of tuples (the vertices of the starting polygon), an integer maxiter, and the optional argument filled (which defaults to False) and which produces the picture of the Koch snowflake obtained by applying koch_iteration() maxiter times, starting with the vertices given in the list. Hint: To connect a list of points (tuples) by line segments, you can use the polygon2d() command. Read its documentation, you probably want to use the options fill=filled,axes=False.

(e) Write a function, called regpolygon(), which takes as input an integer k, and which returns a list of k tuples which are the vertices of the regular polygon with radius 1. In other words, the k points should lie on the unit circle and should be evenly spaced apart. Hint: Use cos α and sin α, where α is a multiple of 2π/k.

(f) Draw the Koch snowflake after 5 iterations when starting with an equilateral triangle. Hint: Use koch_snowflake(regpolygon(3),5).

(g) Draw the Koch snowflake after 5 iterations when starting with a square.

(h) Draw the Koch snowflake after 5 iterations when starting with a pentagon.

(i) Repeat the last three parts, but with the option filled=True.

In: Computer Science

please provide example(s) how you have used excel to analyze data and share your results?? this...

please provide example(s) how you have used excel to analyze data and share your results??
this is more like a inteview question but i want to nniw its sample answer

In: Computer Science

java NetBeans Class Entry: Implement the class Entry that has a name (String), phoneNumber (String), and...

java NetBeans

Class Entry:

  1. Implement the class Entry that has a name (String), phoneNumber (String), and address (String).
  2. Implement the initialization constructor .
  3. Implement the setters and getters for all attributes.
  4. Implement the toString() method to display all attributes.
  5. Implement the equals (Entry other) to determine if two entries are equal to each other. Two entries are considered equal if they have the same name, phoneNumber, and address.
  6. Implement the compareTo (Entry other) method that returns 0 if the two entries have the same number, -1 if this.number is smaller than other.number, and + 1 if this.number is > other.number

Class PhoneBook

  1. Implement the class PhoneBook that has a city (String), type (String), entryList (an ArrayList of Entry).
  2. Implement the constructors to initialize the city and type.
  3. Implement the method addEntryToPhoneBook(Entry e) that adds an entry to the phone book.
  4. Implement the method toString() that displays all attributes and all enties information of the phone book.
  5. Implement the method displayAll() that displays all entries in the phone book.
  6. Implement the method checkEntryByNumber(String number) that takes a number and returns the entry with that number if it exists.
  7. Implement the method checkEntrisByName(String name) that takes a name, and returns an array list of the entries that start with this name or letters.
  8. Implement the method removeEntryFromPhoneBook (String number) that removes an entry from the arrayList of entires in the phone book.

Class TestPhoneBook

  1. Create a phone book and initialize its attributes.
  2. Add 5 entries to the phone book list using the method addEntryToPhoneBook()
  3. Display all entries in the phone book.
  4. Display the entry information for a given phone number if it exists. Give the appropriate message if it does not exist.
  5. Display all entries starting with the letters "Abd"
  6. Remove a specific entry from the phone book. Display the proper message if it was removed , or if it did not exist.
  7. Sort and display the entries of the phone book

In: Computer Science

Write a Problem analysis chart  & an algorithm, create an IPO and draw a flowchart for solving...

Write a Problem analysis chart  & an algorithm, create an IPO and draw a flowchart for solving a Quadratic equation.

In: Computer Science