Questions
Algorithm design:Suppose that three types of parentheses are allowed in an expression: parentheses, square brackets, and...

Algorithm design:Suppose that three types of parentheses are allowed in an expression: parentheses, square brackets, and curly braces. Please design an efficient algorithm to determine whether the parentheses in the expression are correctly paired. Please write down the algorithm idea and steps.

Please explain what kind of data structure is used to solve the problem, and then give the specific algorithm steps

In: Computer Science

Hello. I'm trying to write down java code making stars whose numbers are determined by user...

Hello. I'm trying to write down java code making stars whose numbers are determined by user input on the console (each star's data are stored in ArrayList).

the class extends JFrame and its color, size(Zoom in and Zoom out), and location are changing every time.

Moreover, its angular rotation is changed at a certain determined degree.

Does anyone know how to write down the java code of this question?

In: Computer Science

Describe domain concept briefly. What are the benefits of domain infrastructure when comparing to workgroup networking?...

Describe domain concept briefly. What are the benefits of domain infrastructure when comparing to workgroup networking? Your elaboration using live example is required.

In: Computer Science

1 Demonstrate the use of local variables in a Java program that has 1 function 2...

1
Demonstrate the use of local variables in a Java program that has
1 function

2
Demonstrate the use of overloaded methods
each has three primitive parameters
two methods computes and returns the product to the calling method for printing
one method computes and prints the product; does not return a result

3
Demonstrate the use of overloaded constructors
Three constructors each initialize two variables
Three methods, 1 computes the radius of a circle, 1 computes the area of a rectangle, and area of sphere

In: Computer Science

n following code if variable n=0, a=5 and b=10 then what will be the value of...

n following code if variable n=0, a=5 and b=10 then what will be the value of variable ‘n’ after while loop executed. Show your working as well.

while(n<=(a^b)) { n++; } printf("%d",n)

In: Computer Science

Describe/explain IoT as a tech innovation that is reshaping the infrastructure of cities. Discuss the application...

Describe/explain IoT as a tech innovation that is reshaping the infrastructure of cities. Discuss the application of IoT in three service sectors, be sure to include the application groups, locations and devices

In: Computer Science

C Programming Question: Write a C - program to implement the following three operations: a) Breadth-first...

C Programming Question:

Write a C - program to implement the following three operations:

a) Breadth-first search using Adjacency List

b) Breadth-first search using Adjacency Matrix

c) Check whether a given graph is Bipartite using Breadth-first search (adjacency list).​​​​​​

Please take your time, but do submit the correct and full code. Thank you very much.

In: Computer Science

Circle Class (This is in JAVA) /** * Defines a basic shape with just area *...

Circle Class (This is in JAVA)

/**
 * Defines a basic shape with just area
 *
 * @author Jo Belle
 * @version 0.2 (10/05/2020)
 */
public class Shape{
    private double area;

    public Shape(){ area = 0.0; }
    public Shape( double a ){ this.area = a; }
    public void setArea( double a ){ area = a; }
    public double getArea(){ return area; }
    public String toString(){
        return "Shape:\n\tarea: " + area;
    }
}
/**
 * Create a simple Circle object
 *
 * @author Jo Belle
 * @version 0.2 (10/12/2020)
 */
public class ShapeDriver{
    public static void main( String[] args ){
        Circle cir = new Circle( );
        cir.setRadius( 5.0 );
        System.out.println( cir.toString() );
    }
}

Given the code above, write a Circle class (and save it in a file named Circle.java) that inherits from the Shape class. Include in your Circle class, a single private field double radius. Also include a method void setRadius(double r) (which also sets area) and a method double getRadius() (which also returns the current radius). Change the accessibility modifier for area in the Shape class to be more appropriate for a base class. Make sure that ShapeDriver's main() method executes and produces the following output:

Shape:
        area: 78.53981633974483
        radius: 5.0

Submit both your Circle.java and your Shape.java files.

In: Computer Science

Develop the following class: Class Name: ImprovedArrayBasedStack Access Modifier: public Implements: ImprovedStackInterface Instance variables Name: top...

Develop the following class: Class Name: ImprovedArrayBasedStack Access Modifier: public Implements: ImprovedStackInterface Instance variables Name: top Access modifier: private Data type: int Name: stack Access modifier: private Data type: T[] (an array of parameterized type) Constructors Name: ImprovedArrayBasedStack Access modifier: public Parameters: none (default constructor) Task: sets the value of top to -1 sets the stack to refer to an array of Objects with 100 elements which are type cast to T[] Name: ImprovedArrayBasedStack Access modifier: public Parameters: size (data type int) Task: sets the value of top to -1 sets the stack to refer to an array of Objects with the number of elements equal to the size parameter which are type cast to T[] Methods Name: push Access modifier: public Parameters: item (data type T, parameterized type) Return type: void Throws: StackFullException Task: if the value of top is less than the length of the stack minus 1 then increase the value of top by 1 and place the item at the top of the stack, otherwise throw a StackFullException with the message "Not enough room for one item" Name: push Access modifier: public Parameters: item1 (data type T, parameterized type), item2 (data type T, parameterized type) Return type: void Throws: StackFullException Task: if the value of top is less than the length of the stack minus 2, then increase the value of top by 1 and place item1 at the top of the stack, then increase the value of top by 1 and place item2 at the top of the stack, otherwise throw a StackFullException with the message "Not enough room for two items" Name: pop Access modifier: public Parameters: none Return type: void Throws: StackEmptyException Task: if the value of top is greater than -1 then remove the item at the top of the stack by replacing it with null and decrease the value of top by 1, otherwise throw a StackEmptyException with the message "No item to remove" Name: doublePop Access modifier: public Parameters: none Return type: void Throws: StackEmptyException Task: if the value of top is greater than 0, then remove the item at the top of the stack by replacing it with null and decrease the value of top by 1, then remove the item at the top of the stack by replacing it with null and decrease the value of top by 1, otherwise throw a StackEmptyException with the message "There are less than two items in the stack" Name: top Access modifier: public Parameters: none Return type: T (parameterized type) Throws: StackEmptyException Task: if the value of top is greater than -1 then return the item at the top of the stack, otherwise throw a StackEmptyException with the message "Top attempted on an empty stack"

In: Computer Science

Suppose you define the class myGrid in Java. Suppose further that my Image[][] is a variable...

Suppose you define the class myGrid in Java. Suppose further that my Image[][] is a variable defined to be a 2D array with 100 rows and 100 columns of type myGrid, and that the myGrid class has two methods: setX()and setY(). Write the Java code snippet to instantiate every cell of myImage[][]with myGrid objects, and use the setX()and setY()methods to store the row and the column location of each myGrid object in the array.

In: Computer Science

For this question you need to write some methods and class headers. (a) Assume that you...

  1. For this question you need to write some methods and class headers.

    1. (a) Assume that you have written a Rectangle class with instance variables length and width. You have already written all set and get methods and area and perimeter methods. Write an equals() method that takes Object o as a parameter. The method should return true when the Object o is a rectangle with the same length and width.

      Answer:

    2. (b) A class named Fruit implements an interface called Edible. The interface has a single method called howToEat(). A class called Orange extends Fruit and implements Edi- ble. Write the class header for the Orange class and override the howToEat() method of the Fruit class. The method should print a brief message to the screen about how to eat an orange. Do not write any other methods or constructors.

      Answer:

In: Computer Science

Choose a pivot using the median of 3 technique and show the result after 1 pass...

Choose a pivot using the median of 3 technique and show the result after 1 pass of quicksort (stop just before choosing a 2nd pivot) for the list [ 85, 40,60, 30, 55, 63, 70, 75 ,25]

In: Computer Science

Write the algorithm in pseudocode for scan-converting (filling in the interior) of an axis-aligned right triangle...

Write the algorithm in pseudocode for scan-converting (filling in the interior) of an axis-aligned right triangle (the base is aligned with the x-axis and the orthogonal leg is aligned with the y-axis).

In: Computer Science

Create a Java method that takes a String as input value and returns the number of...

Create a Java method that takes a String as input value and returns the number of vowels contained in that string.

In: Computer Science

(JAVA) For your homework, I want you to create the order of your mini-programs based on...

(JAVA)
For your homework, I want you to create the order of your mini-programs based on how it is listed in this assignment description (i.e., Program 1 should be the first program implemented, Program 2 should be the second program, etc.). All your mini-programs are housed inside one main method. The name of your class for this homework should be called Homework3. You will be submitting that single Java file to this submission box. There are a total of two mini-programs you have to implement, and each program is worth 40 points for functioning code and correct outputs. Altogether, the programs are 80 points in total; the remaining 20 points reflect your programming style and documentation.

Program 1 - Palindrome

A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554, and 11611. Write an application that reads in a five-digit integer and determines whether it's a palindrome. If the number is not five digits long, display an error message and allow the user to enter a new value.

Sample Input
Enter a number: 11611

Sample Output
11611 is a palindrome.
Sample Input
Enter a number: 55953

Sample Output
55953 is not a palindrome.
Sample Input
Enter a number: 1151
Enter a number: 3920
Enter a number: 12321

Sample Output
12321 is a palindrome.
Sample Input
Enter a number: 116611
Enter a number: 999999
Enter a number: 99989

Sample Output
99989 is not a palindrome.

Program 2 - Printing the Decimal Equivalent of a Binary Number

Write an application that inputs an integer containing only 0s and 1s (i.e., a binary integer) and prints its decimal equivalent. [Hint: Use the remainder and division operators to pick off the binary number's, digits one at a time, from right to left. In the decimal number system, the rightmost digit has a positional value of 1 and the next digit to the left a positional value of 10, then 100, then 1000, and so on. The decimal number 234 can be interpreted as 4 * 1 + 3 * 10 + 2 * 100. In the binary number system, the rightmost digit has a positional value of 1, the next digit to the left a positional value of 2, then 4, then 8, and so on. The decimal equivalent of binary 1101 is 1* 1 + 0 * 2 + 1 * 4 + 1 * 8, 1 + 0 + 4 + 8, or 13]

Sample Input
Enter a binary number: 1101

Sample Output
13 is the decimal equivalent of 1101
Sample Input
Enter a binary number: 1000110

Sample Output
70 is the decimal equivalent of 1000110
Sample Input
Enter a binary number: 11111111

Sample Output
255 is the decimal equivalent of 11111111
Sample Input
Enter a binary number: 1001001110

Sample Output
590 is the decimal equivalent of 1001001110

In: Computer Science