Questions
//JAVA //basic please for learning programming 2. Thank you. Write the Class Variables Class Box is...

//JAVA
//basic please for learning programming 2. Thank you.

Write the Class Variables
Class Box is to have the following private data members:

  • height of type double
  • width of type double
  • length of type double

Write the following Overridden Method
Class Box is to have an overridden equals() method that does the following:​​​​

  • tests to see if the parameter represents an object (null test)
  • tests to see if the parameter object is of the same class type as the calling object (class test)
  • determines if the calling object and the parameter object store identical data values for the corresponding data members (variable to variable test)

Write the Get and Get Methods
Class Box is to have standard get/set methods for each data member
Write the following Auxiliary Method
Class Box is to have an auxiliary method getVolume( ). The method is to have an access of public and return a value of type double. The method is to do the following:

  • calculate and return the volume of the box
  • volume is calculated by multiplying the length of the box by the width of the box by the height of the box

Write the Constructors
Class Box is to have two constructors with the following specifications:

  • a no-arg constructor that initializes each double data member to zero
  • a constructor that takes three parameters, each representing one of the class data members. the arguments are to be listed in the order of (height, width, length)

Class: Box
Write the class header
Write the following Overridden Method
Class Box is to have an overridden toString() method that does the following:

  • displays the following information in the format presented:

Height: display height of the object
Width: display the width of the object
Length: display the length of the object
Write the following application class: BoxApp.

Class BoxApp is to do the following:

  • create an object of type Box named smallBox that has a height of 3, a width of 4 and a length of 5;
  • create an object of type Box named mediumBox that has a height of 6, a width of 7 and a length of 8;
  • create an object of type Box named unknownBox that has a height of 0, a width of 0 and a length of 0;
  • test to see if smallBox equals unknown box. If they are equal, display the word true. If they are not equal, display the word false.
  • output the following information for smallBox

Height: the value of the height property
Width: the value of the width property
Length: the value of the length property

In: Computer Science

Convert UTF-8 to UTF-16 and Back Write two Java programs and verify that they work. Program...

Convert UTF-8 to UTF-16 and Back

Write two Java programs and verify that they work.

Program 1 should:

  • Read a UTF-8 encoded text file
  • Print to the console the hex values for the bytes it read in.
  • Convert the text to UTF-16
  • Print to the console the hex values for the converted bytes
  • Write the UTF-16 text to a file

Program 2 should do the same as program 1, except program 2 goes from UTF-16 to UTF-8

Submit:

  1. UTF8ToUTF16.java
  2. UTF16ToUTF8.java
  3. A sample utf8 input file
  4. A sample utf 16 output file
  5. A sample utf 16 input file
  6. A sample utf 8 output file
  7. A screenshot of your computer running program 1
  8. A screenshot of your computer running program 2

import java.io.*;

public class WriteUTF8 {
  
   public static void main(String[] args) {
       File file = new File("utf8_output.txt");
       FileOutputStream fs= null;
       try {
           fs = new FileOutputStream(file);
       }
       catch (FileNotFoundException fnfe) {
           System.err.println("file not found");
       }
       try {
           fs.write("Фёдор".getBytes("UTF-8"));
           fs.close();
       }
       catch(IOException ioe){
           System.err.println("unable to write to file");
       }
   }
}
---

import java.io.*;

public class WriteUTF16 {
  
   public static void main(String[] args) {
       File file = new File("utf16_output.txt");
       FileOutputStream fs= null;
       try {
           fs = new FileOutputStream(file);
       }
       catch (FileNotFoundException fnfe) {
           System.err.println("file not found");
       }
       try {
           fs.write("Фёдор".getBytes("UTF-16"));
           fs.close();
       }
       catch(IOException ioe){
           System.err.println("unable to write to file");
       }
   }
}
--

In: Computer Science

1a) Write the start of the class declaration for a node in a linked list (give...

1a) Write the start of the class declaration for a node in a linked list (give the name of the class and the instance variables). The name of the node should be SpecialNode. The data in each SpecialNode will include both a String and a Song object.

b)Using the SpecialNode class you created in question above, write a constructor forSpecialNode that has three parameters and initializes all the SpecialNode instance variables.

c) Write a line of code to instantiate a SpecialNode object to initialize the SpecialNodeinstance variables. Use the constructor you wrote in the previous question.

Song rockstar = new Song("Rockstar", 5);

SpecialNode sn = ___________________________________ ;

In: Computer Science

I am using NetBeans IDE Java for coding. I would like the code to be commented...

I am using NetBeans IDE Java for coding. I would like the code to be commented for a better understanding.

1. Implement a class Robot that simulates a robot wandering on an infinite plane. The robot is located at a point with integer coordinates and faces north, east, south, or west.

Supply methods:

public void turnLeft()

public void turnRight()

public void move()

public Point getLocation()

public String getDirection()

The turnLeft and turnRight methods change the direction but not the location. The move method moves the robot by one unit in the direction it is facing. The getDirection method returns a string "N", "E", "S", or "W".

In: Computer Science

1. Provide an explanation of the network detection methods in the chapter, give an example of...

1. Provide an explanation of the network detection methods in the chapter, give an example of their importance and discuss the issue(s) associated with each method.


In: Computer Science

Operating systems typically split functionality into layers. Explain the advantages and disadvantages of the structure of...

Operating systems typically split functionality into layers. Explain the advantages and disadvantages of the structure of software as layers in distributed systems.

In: Computer Science

Q2) Using the program in Figure 2, identify the values of pid at lines A, B,...

Q2) Using the program in Figure 2, identify the values of pid at lines A, B, C, and D. (Assume that the actual pids of the parent and child are 2600 and 2603, respectively.) Give a brief explanation.

#include <sys/types.h> #include <sys/wait.h> #include <stdio.h> #include <unistd.h>

int main() { pid_t pid, pid1; /*fork a child process*/

pid = fork(); if (pid < 0) { /* error occurred*/ fprintf(stderr, "Fork Failed"); return 1; } else if (pid == 0) { /*child process*/ pid1 = getpid(); printf("child: pid = %d", pid); /* A */ printf("child: pid1 = %d", pid1); /* B */ } else { /*parent process*/ pid1 = getpid(); printf("parent: pid = %d", pid); /* C */ printf("parent: pid1 = %d", pid1); /* D */ wait(NULL); }

return 0; }

Figure 2 - What are the pid values displayed?

In: Computer Science

Question 1 What Unix command can be used to change the access permission of a file...

Question 1

  1. What Unix command can be used to change the access permission of a file ?   and how ?

  1. Explain how pipe works in Unix. Give one example; Explain how redirect works in Unix and give an example.

  1. Explain the structure of Unix file system and how absolute and relative paths work

  1. What is UML ?   Briefly explain two types of diagrams in UML.

  1. Briefly explain two types of testing methods for software development and the major stages in software development cycles

In: Computer Science

how to add n gram code for this program? import nltk from textblob import TextBlob from...

how to add n gram code for this program?

import nltk
from textblob import TextBlob
from collections import Counter

from nltk import FreqDist
file=open("veg.txt","r")
rd=file.read()

#sentiment
sentences= nltk.sent_tokenize(rd)
tb=(TextBlob (t).sentiment.polarity for t in rd)
tb=TextBlob(rd)
print(tb.sentiment.polarity)

#ner
words=[]
for sentence in sentences:
words.append(nltk.word_tokenize(sentence))
tags=[]
for word in words:
tags.append(nltk.pos_tag(word))
for tag in tags:
print(nltk.ne_chunk(tag))

#pos
print(tb.tags)

wordlist = rd.split()
wordfreq = []
for w in wordlist:
wordfreq.append(wordlist.count(w))
print("Word Frequency\n" + str(list(zip(wordlist, wordfreq))))

In: Computer Science

On Android Studio, create a 4 function calculator. The only buttons you need are 0-9, *,...

On Android Studio, create a 4 function calculator. The only buttons you need are 0-9, *, /, +, -, a clear, and enter button. Having this java code, I need the XML code that organizes the layout of the calculator.

JAVA CODE -

package com.example.10012698.calculatorproject;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.StringTokenizer;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {

Button button0, button1, button2, button3, button4, button5, button6,
button7, button8, button9, buttonadd, buttonsubtract, buttonmultiply,
buttondivide, buttonequals, buttonclear;
TextView display;
String displaytext="";
double result;
double x, y;
ArrayList<String> list;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

button0 = (Button) findViewById(R.id.button0);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button3 = (Button) findViewById(R.id.button3);
button4 = (Button) findViewById(R.id.button4);
button5 = (Button) findViewById(R.id.button5);
button6 = (Button) findViewById(R.id.button6);
button7 = (Button) findViewById(R.id.button7);
button8 = (Button) findViewById(R.id.button8);
button9 = (Button) findViewById(R.id.button9);
buttonadd = (Button) findViewById(R.id.buttonadd);
buttonsubtract = (Button) findViewById(R.id.buttonsubtract);
buttonmultiply = (Button) findViewById(R.id.buttonmultiply);
buttondivide = (Button) findViewById(R.id.buttondivide);
buttonclear = (Button) findViewById(R.id.buttonclear);
buttonequals = (Button) findViewById(R.id.buttonequals);
display = (TextView) findViewById(R.id.display);
display.setOnClickListener(this);
list = new ArrayList<>();
}

public void onClick(View view)
{
if(!(view.equals(buttonclear)&&!(view.equals(buttonequals))))
{
display.setText(display.getText()+""+((Button)view).getText());

if(displaytext.equals("0"))
{
display.setText(" ");
}

if(view.equals(buttonclear))
{
display.setText(" ");
}

if(view.equals(buttonequals))
{
displaytext= displaytext.substring(0,displaytext.length()-1);
StringTokenizer operators= new StringTokenizer(displaytext, "+-*/",true);

while(operators.hasMoreTokens())
{
list.add(operators.nextToken());
}

for(int j=0; j<list.size()-1; j++)
{
if (list.get(j).equals("*") || list.get(j).equals("/"))
{
x = Double.parseDouble(list.get(j - 1));
y = Double.parseDouble(list.get(j + 1));

if (list.get(j).equals("*"))
{
result+=(x*y);
}

if (list.get(j).equals("/"))
{
result+=(x/y);
}
}
}
for(int k=0;k<list.size()-1;k++)
{
if (list.get(k).equals("+") || list.get(k).equals("-"))
{
x = Double.parseDouble(list.get(k - 1));
y = Double.parseDouble(list.get(k + 1));

if (list.get(k).equals("+"))
{
result+=(x+y);
}

if (list.get(k).equals("-"))
{
result+=(x-y);
}
}
}
}
display.setText(""+result);


}
}

In: Computer Science

Python Loop invariant To show that an assertion A is a loop invariant , is it...

Python Loop invariant

To show that an assertion A is a loop invariant , is it enough to argue that the execuation of the loopbody preserves A? Please desscribe it throughly.

In: Computer Science

Write C++ programs to implement Queue ADT data structure using Linked List.

Write C++ programs to implement Queue ADT data structure using Linked List.

In: Computer Science

Try to make it as simple as you can. Please provide the answers with some examples...

Try to make it as simple as you can. Please provide the answers with some examples as fast as you can.

1-Which of the following best defines a computer used as a server?

a)Computer hardware that includes fast disk drives and a lot of memory

b)Operating system software that includes clients, such as a Web browser and Client for Microsoft Networks

c)Operating system software that includes directory services and domain name services

d)A computer with Linux installed.

2-If you want to make a computer a domain controller, which of the following should you installed?

a)Client for Microsoft Networks

b)File and Printer Sharing for Microsoft Networks

c)Domain Name Services

d)Active Directory

3-You have been asked to advise a business on how best to set up its Windows network. Eight workstations are running Windows Vista Business. The business recently acquires a new contract that requires running a network application on a server. A secure and reliable environment is critical to run this application, and security management should be centralized. There is enough budgets for new hardware and software, if necessary. Which Windows networking model should you advise this business to use?

a)A Windows domain using Active Directory    b)A Window workgroup using Active Directory

c)A peer –to-peer network using File and Printer Sharing   d)A peer-to-peer network using Active Directory

4-What command should you use to test your IP configuration settings after a new Windows Server 2012 installation?

a)Dir

b)Arp

c)Ping

d)Hostname

5-Which of the following is a reason for installing a new server? (Choose all that apply.)

a)Excessive load on existing servers

b)Fault tolerance

c)Adding a new network protocol

d)To isolate a new application

6-Which of the following is a feature of Active Directory? (Choose all that apply.)

a) Fine-grained access controls

b) Can be distributed among many servers

c) Can have only one server

d) Has a fixed schema

7-Which of the following is the responsibility of domain controllers? (Choose all that apply.)

a) Storing a copy of the domain data

b) Providing data search and retrieval functions

c) Servicing multiple domains

d) Providing authentication services

8-Which of the following is associated with an Active Directory forest? (Choose all that apply.)

a)Contains trees with different naming structures   b)Allows independent domain administration

c)Contains domains with different schemas    d)Represents the broadest element in Active Directory

9-Which of the following defines the types of objects in Active Directory?

a) GOPs

b) Attribute values

c) Schema attributes

d) Schema classes

10-Which container has a default GPO linked to it?

a)Users

b)Printers

c)Computers

d)Domain

In: Computer Science

int count = 10; while (count >= 0) { cout << count << endl; count =...

int count = 10;
while (count >= 0)
{
cout << count << endl;
count = count + 3;
}

How many times will this loop be executed?

  • A.

    Endless loop

  • B.

    3 times

  • C.

    0 times

  • D.

    Once

In: Computer Science

Try to make it as simple as you can. Please provide the answers with some examples...

Try to make it as simple as you can. Please provide the answers with some examples as fast as you can.

1-Which of the following best defines a computer used as a server?

a)Computer hardware that includes fast disk drives and a lot of memory

b)Operating system software that includes clients, such as a Web browser and Client for Microsoft Networks

c)Operating system software that includes directory services and domain name services

d)A computer with Linux installed.

2-If you want to make a computer a domain controller, which of the following should you installed?

a)Client for Microsoft Networks

b)File and Printer Sharing for Microsoft Networks

c)Domain Name Services

d)Active Directory

3-You have been asked to advise a business on how best to set up its Windows network. Eight workstations are running Windows Vista Business. The business recently acquires a new contract that requires running a network application on a server. A secure and reliable environment is critical to run this application, and security management should be centralized. There is enough budgets for new hardware and software, if necessary. Which Windows networking model should you advise this business to use?

a)A Windows domain using Active Directory    b)A Window workgroup using Active Directory

c)A peer –to-peer network using File and Printer Sharing   d)A peer-to-peer network using Active Directory

4-What command should you use to test your IP configuration settings after a new Windows Server 2012 installation?

a)Dir

b)Arp

c)Ping

d)Hostname

5-Which of the following is a reason for installing a new server? (Choose all that apply.)

a)Excessive load on existing servers

b)Fault tolerance

c)Adding a new network protocol

d)To isolate a new application

6-Which of the following is a feature of Active Directory? (Choose all that apply.)

a) Fine-grained access controls

b) Can be distributed among many servers

c) Can have only one server

d) Has a fixed schema

7-Which of the following is the responsibility of domain controllers? (Choose all that apply.)

a) Storing a copy of the domain data

b) Providing data search and retrieval functions

c) Servicing multiple domains

d) Providing authentication services

8-Which of the following is associated with an Active Directory forest? (Choose all that apply.)

a)Contains trees with different naming structures   b)Allows independent domain administration

c)Contains domains with different schemas    d)Represents the broadest element in Active Directory

9-Which of the following defines the types of objects in Active Directory?

a) GOPs

b) Attribute values

c) Schema attributes

d) Schema classes

10-Which container has a default GPO linked to it?

a)Users

b)Printers

c)Computers

d)Domain

In: Computer Science