Questions
Hierarchical clustering is sometimes used to generate K clusters, K > 1 by taking the clusters...

Hierarchical clustering is sometimes used to generate K clusters, K > 1 by taking the clusters at the K th level of the dendrogram. (Root is at level 1.) By looking at the clusters produced in this way, we can evaluate the behavior of hierarchical clustering on different types of data and clusters, and also compare hierarchical approaches to K-means.
The following is a set of one-dimensional points: {6, 12, 18, 24, 30, 42, 48}.

(a)
For each of the following sets of initial centroids, create two clusters by assigning each point to the nearest centroid, and then calculate the total squared error for each set of two clusters. Show both the clusters and the total squared error for each set of centroids.
i.{18, 45}
ii. {15, 40}
(b)
Do both sets of centroids represent stable solutions; i.e., if the K-means algorithm was run on this set of points using the given centroids as the starting centroids, would there be any change in the clusters generated?
(c)
What are the two clusters produced by single link?
( d) Which technique, K-means or single link, seems to produce the "most natural" clustering in this situation? (For K-means, take the clustering with the lowest squared error.)
(e)
What definition(s) of clustering does this natural clustering correspond to? (Well-separated, center-based, contiguous, or density.)
(f)
What well-known characteristic of the K-means algorithm explains the previous behavior?

In: Computer Science

CODE IN JAVA A computer company sells software and computer packages for $75. Quantity discounts are...

CODE IN JAVA

A computer company sells software and computer packages for $75. Quantity discounts are given based on the following criteria:

Quantity          Discount

10 - 19             20%
20 - 49             30%
50 - 99             40%
100 or more    50%

Be sure the user is presented with all necessary information, then prompt the user for the quantity of packages. Display the total cost of the purchase making sure to apply appropriate discounts.

Example Output:

Demon software and computers is offering discounts on the Vic Package. This package includes a computer and needed software to perform basic daily functions. The Vic package sells for $75.00. Discounts are given based on quantity. The discounts are listed below:

10 - 19 gives a 20% discount
20 - 49 gives a 30% discount
50 - 99 gives a 40% discount
100 or more gives a 50% discount

How many would you like to purchase?

25

You purchased 25 packages. Your total is $1312.50

In: Computer Science

Write a query that returns all of the main information that are associated with the purchase...

Write a query that returns all of the main information that are associated with the purchase orders that have an amount greater than 70% of the average amount of all purchase orders, the output should be sorted by the largest purchase order amount

In: Computer Science

public class Classroom { // fields private String roomNumber; private String buildingName; private int capacity; /**...

public class Classroom
{
// fields
private String roomNumber;
private String buildingName;
private int capacity;

/**
* Constructor for objects of class Classroom
*/
public Classroom()
{
this.capacity = 0;
}
  
/**
* Constructor for objects of class Classroom
*
* @param rN the room number
* @param bN the building name
* @param c the room capacity
*/
public Classroom(String rN, String bN, int c)
{
setRoomNumber(rN);
setBuildingName(bN);
setCapacity(c);
}
  
/**
* Mutator method (setter) for room number.
*
* @param rN a new room number
*/
public void setRoomNumber(String rN)
{
this.roomNumber = rN;
}
  
/**
* Mutator method (setter) for building name.
*
* @param bN a new building name
*/
public void setBuildingName(String bN)
{
this.buildingName = bN;
}
  
/**
* Mutator method (setter) for capacity.
*
* @param c a new capacity
*/
public void setCapacity(int c)
{
this.capacity = c;
}
  
/**
* Accessor method (getter) for room number.
*
* @return the room number
*/
public String getRoomNumber()
{
return this.roomNumber;
}
  
/**
* Accessor method (getter) for building name.
*
* @return the building name
*/
public String getBuildingName()
{
return this.buildingName;
}
  
/**
* Accessor method (getter) for capacity.
*
* @return the capacity
*/
public int getCapacity()
{
return this.capacity;
}
}

  1. Modify this class so that it implements the Comparable interface. This will involve adding a method called compareTo() to your Room class and making some other changes to the class definition.
  2. Now write a main program (in a new class called TestComparable) that creates an ArrayList of Rooms. Add about 5 Rooms to the list so that they're randomly ordered. Print the list in its current order. Then call the sort() method to sort the Rooms based on capacity. Print the list in the new sorted order.

In: Computer Science

1.  Give the top five most popular operating systems of the world. Justify your answer and explain...

1.  Give the top five most popular operating systems of the world. Justify your answer and explain why they are the most popular.

2.(a) What is the biggest advantage of implementing thread in user space? What is the biggest disadvantage?

(b) What is the biggest advantage of implementing thread in kernel space? What is the biggest disadvantage?

In: Computer Science

Playing with encryption: Write a program that will read a four-digit integer entered by the user...

Playing with encryption:

Write a program that will read a four-digit integer entered by the user and encrypt it as follows: Replace each digit with the result of adding 7 to the digit and getting the remainder after dividing the new value by 10. Then swap the second digit with the fourth. Finally, print the original number and its encrypted one. Now reverse the process. Read an encrypted integer and decrypt it by reversing the algorithm to obtain the original number. Print out both the encrypted and decrypted integer.

In: Computer Science

please write the code in C format avoid using (<<count>>) Assume that you work for a...

please write the code in C format avoid using (<<count>>)

Assume that you work for a travel agency. Write a C program that performs 7 different tasks described below
for this company. The flights have the following
daily departure and arrival times:

hotel name cost ride cost
Rose 248$ 0$
Poprock 90$ 25$
flower 128$ 20$
departure time arrival time cost
7:15 am 8:25am 231$
8:15 am 9:25am 226$
9:15am 10:25am 226$
10:15am 11:25am 283$
11:15am 12:25pm 283$
3:15pm 4:25pm 226$
4:15pm 5:25pm 226$
5:15pm 6:25pm 401$

a) Based on the time entered by the customer, the closest departure time is displayed using 12- hour format.

b)the customer is asked if they would like a hotel and for how many days. hotel cost is mentioned above. Calculate the total cost (before taxes) and display it (flight + hotel for n number of days +ride).

c) now there is 2 types of discount:
Discount1: If the total fee is a multiple of 11, then the
customer gets a 6% discount.
Discount2: An additional discount of 7% is given to those customers whose subtotal
after discount1 is a multiple of the sum of digits of the customer’s day of birth.
Three examples are given below for your convenience. See Sample Input / output
for more clarification.
• Ex1: If the day of birth entered is 3, the customer will get an additional 7%
discount if the sub-total of their purchase after discount1 is a multiple of 3.
• Ex 2: If the day of birth entered is 12, the customer will get an additional 7%
discount if their purchase after discount1 is a multiple of 3 (since sum of digits of
day of birth (12) is 3).

c)13% tax is applied to the total cost and the final bill is?

In: Computer Science

I am having a hard time with these questions regarding JDBC and XML. 1) Which type...

I am having a hard time with these questions regarding JDBC and XML.

1)

Which type of driver provides JDBC access via one or more ODBC drivers?

Group of answer choices

a) Type 1 driver

b) Type 2 driver

c) Type 3 driver

d) Type 4 driver

2)

Which of the following provides the application-to-JDBC Manager connection.

a) JDBC Driver

b) JDBC API

c) JDBC Driver API

d) SQL Server

3)

With the code below, indicate JDBC coding best practices that have been violated (this code does compile and run!):

import java.sql.*;

public class StudentData{
public static void main(String[] args) {
ResultSet rs = null;
Statement stmt = null;
Connection conn = null;
try {
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection(args[2], args[0], args[1]);
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT * FROM Student WHERE rollno='" + args[3] + "'");

while (rs.next()) {
System.out.print(rs.getInt(1) + "\t");
System.out.print(rs.getString(2) + "\t ");
System.out.print(rs.getInt(3) + "\t ");
System.out.println(rs.getDate(4));
}
stmt.close();
stmt = null;
rs.close();
rs = null;
}
catch (Exception exc) {
exc.printStackTrace();
}
}
}

  

a) The program imports all of the java.sql packages

b) This program does not properly close database resources

c) The program should catch SQLException

d) The program should not string-concatenate a query, but rather use a PreparedStatement.

e) The program retrieves data from a ResultSet by column number instead of by name

f) The program hardcodes the name of the JDBC driver and the SQL query. These should be externalized from the compilable code.

g) Answer 1, 3 and 5 only

h) Answers 1-6 all apply

4)

In JDBC, it is a good practice to use standard SQL statement and avoid using db specific query until necessary.

a) True

b) False

In: Computer Science

Windows 10: Cortana and Windows Search Why might you or a business might want to remove...

Windows 10: Cortana and Windows Search

  1. Why might you or a business might want to remove metadata from a document, or a photo shared on the web?
  2. Where must the text you type in a search appear in a word?
  3. How would you search for files between 0-16KB?
  4. Pick a date about one week ago. In File Explorer’s search box, find all files that were modified before that date. What search command did you use?

In: Computer Science

Trying to create a Class of Employees that holds every Employee created from a class called...

Trying to create a Class of Employees that holds every Employee created from a class called Employee in c++

In: Computer Science

C++ The minimum function. (a) Write a function that takes two integers and returns the value...

C++ The minimum function.

(a) Write a function that takes two integers and returns the value of the smaller one. In the main() function provide 5 test cases to verify its correctness. (b) Write the function that takes two characters and return the smaller one in the lexicographical order. Write the main() function that tests that functions for 5 different pairs of character type variables. (c) Write a generic function that takes two numeric objects and returns the value of the smaller one according to the less-than operation. Test the function in main() using the integer and character types.

In: Computer Science

Consider two sets of integers, X = [x1, x2, . . . , xn] and Y...

Consider two sets of integers, X = [x1, x2, . . . , xn] and Y = [y1, y2, . . . , yn]. Write two versions of a FindUncommon(X, Y ) algorithm to find the uncommon elements in both sets.
Each of your algorithms should return an array with the uncommon elements, or an empty array if there are no uncommon elements.
You do not have to write the ‘standard’ algorithms – just use them. Therefore, you should be able to write each algorithm in about 10 lines of code. You must include appropriate
comments in your pseudocode.

(a) Write a pre-sorting based algorithm of FindUncommon(X, Y ). Your algorithm should strictly run in O(n log n).

(b) Write a Hashing based algorithm of FindUncommon(X, Y ). Your algorithm should run in O(n).

In: Computer Science

Topic 2 TRUE OR FALSE Q’s 31.          A natural number is the number 0 or any...

Topic 2 TRUE OR FALSE Q’s

31.          A natural number is the number 0 or any number obtained by adding 1 to a natural number.

32.          The category of numbers called integers includes negative numbers.

33.          A rational number is any number that can be expressed without a fractional part.

34.          The base of a number system determines the number of digits used in the system.

35.          The digits used in any base are 1 through the base number.

36.          The base of the hexadecimal number system is 15.

37.          A number in any base can be expressed using a positional notation.

38.          The letter C is used to represent the number 11 in hexadecimal.

39.          The number 10 represents the base value in every number system.

40.          Representing a number in base 5 sometimes requires more digits than representing that same number in base 10.

41.          The value of each position in a number system is determined by subtracting the base from the position number.

42.          A byte is made up of eight binary digits.

43.          Two hexadecimal digits can be stored in one byte.

44.          Starting from the right, every group of four binary digits can be read as one hexadecimal digit.

45.          To find the decimal equivalent in a new base you just divide the decimal value by the new base.

In: Computer Science

OOPDA in java project. in eclipse Instructions: Create a class called Person with the properties listed:...


OOPDA in java project. in eclipse

Instructions:

  1. Create a class called Person with the properties listed: int id, String firstName, String middleName, String lastName, String email, String ssn, int age.
    The Person class should have getters and setters for all properties
    other than id. (You may use Eclipse to help you auto-generate these.)

    1. Person class should also have a getter for id

    2. Create a no-arg constructor for Person

    3. In addition to these getters and setters, Person should have the
      following instance methods:

  • String toString() – returns full name, like "Edgar Allen Poe"

  • String getEmailDomain() – returns the domain portion of an email (after
    the @), as in "gmail.com"

  • String getLast4SSN() – returns the last 4 digits of the Social Security
    Number

  • Add validation checking methods

    • static boolean validAge(String testAge)

  1. You will have to convert the testAge String to an int to store it after validation

static boolean validEmail(String testEmail)

static boolean validSSN(String testSSN)

for the age, email and ssn.You may have done this via the setters in the past. However, this time, let's make them class-level (static) methods to validate these fields as best you can.

  • Give some thought to what advantages this approach would have.

  1. Notes on validation.

    1. Here is a list of validation checks you should perform. Some are easier to implement than others, and there are many ways to correctly validate these aspects of the fields. Implement as many of these checks as you can.

  • You may accept any value for the names

    • Extra Credit: Is there a good way to validate a name? Do a little research on topic and include your answer. If there is, include your algorithm.

  • Age entered by user  

    • The String entered must be an integer greater than 16

    • If the String is greater than 100 you should log an info message

  • Email address string entered by user

    • String must contain a '@' and at least one '.’

    • A '.' must follow the '@’

    • String must only contain one '@'

    • The domain name (the part after ‘@’ but before the first ‘.’ )must be at least one character in length

Clearly there are far more restrictions on email addresses than those listed above. See if you can think of any others that might be applicable. I will give out extra credit for especially clever email validation tests. Make sure to document and comment your ideas.

Social Security Number string entered by user

  • String must contain two '-' characters in the correct position

  • The length of the SSN must be 11 total characters

  • String must contain only digits or numbers

If you encounter invalid data for any of these fields, log it using the logging API of Java. (Do not use System.out.println(); )

Static variables: Keep track of the highest age entered for a Person in a static variable.

Create a driver program PersonApp to test the class

  1. Prompt user for all Person properties except id. You can hardcode any id you like, but use the id as the HashMap key

  2. Accept any value for the name field

  3. Only accept valid values for age, email and ssn

  4. Create a Person with the valid input

Create subclasses for Instructor and Student

  1. Instructors should have a Department

  2. Students should have a Major

  3. Generate getters and setters

Add the Person, the Student and the Instructor to a HashMap.

  1. In the Driver, create a Student & an Instructor (Hardcoded, do not prompt for Input)

  2. Add each of these three instances (the hardcoded Student & Instructor, and previously created Person ) to a HashMap using the id as the key

Perform the following after creating each person in the Driver:

  1. Loop through the HashMap and display

  • The person's full name and what kind of Person are they

  • The person's email domain

  • The last 4 digits of the person's Social Security Number

  • Whether the person is the oldest in the collection

  • The major for the Student, the department for the Instructor

Here is some sample output, to help you understand the end goal of the exercise (your prompts may look different than mine, don’t worry about that as long as they are clear)


Enter person's first name
Julie
Enter person's middle name
Theresa
Enter person's last name
Collins
Enter person's email address
[email protected]
Enter person's SSN in ###-##-#### format
123-45-6789
Enter person's age
47


Julie Theresa Collins (Person)
acme.com
6789
Oldest


Jane Marie Doe (Student)
students.rowan.edu
4444
not oldest

Computer Science


Stephen J. Hartley (Instructor)
rowan.edu
5555
not oldest
Math/Science

In: Computer Science

Java Define a class called BlogEntry that could be used to store an entry for a...

Java

Define a class called BlogEntry that could be used to store an entry for a Web log.

The class should have instance variables to store :

- the poster’s username,

- text of the entry,

- and the date of the entry using the Date class

Date class is:

class Date

{

private int day, year;

private String mon;

public Date()

{

mon=" ";

day=0;

year=0;

}

public String toString()

{

return (mon+"/"+day+"/"+year);

}

public set_date(String m, int d, int y)

{

mon=m;

day=d;

year=y;

}

}

Methods:

-Add a constructor that allows the user of the class to set all instance variables.

-Also add a method, DisplayEntry()/toString(), that outputs all of the instance variables,

- method called getSummary that returns the first 10 characters from the text (or the entire text if it is less than 10 characters).

.

.

.

.

.

.

my code so far:

import java.util.Scanner;

public class BlogEntry
{
   private String name;
   private String entry;


   public BlogEntry(String n, String e, String m, int d, int y)
   {
       System.out.println("Poster's name: "+n+"\nEntry Text: "+e);
       System.out.println("Date: "+m+" "+d+", "+y);
   }
   public String getName()
   {
       return name;
   }
   public void setName(String n)
   {
       this.name=n;
   }
   public String getEntry()
   {
       return entry;
   }
   public void setEntry(String e)
   {
       this.entry=e;
   }
   class date
   {
   private int d, y;
   private String m;
   public date(String m,int d, int y)
   {
       m= " ";
       d=0;
       y=0;
   }
   public void setdate(String m, int d, int y)
   {
       m=m;
       d=d;
       y=y;
   }
   }
private void String setSummary()
   {
   String summary=" ";
   int space=0;
   int script=0;
   while(space<=9 && script<entry.length())
   {
       String next=entry.substring(script,script+1);
       if(next.equals(" "))
       {
           if(space<=9)
               space++;
           else
               break;
       }
       summary+=next;
       script++;
   }
   return summary;
   }
   public getSummary()
   {
       return summary;
   }

public static void main(String [] args)
{
String name;
String entry;
String month;
int day;
int year;

Scanner input=new Scanner(System.in);

System.out.println("Please enter the Poster's name: ");
name=input.nextLine();

System.out.println("What is the text for the blog entry: ");
entry=input.nextLine();

System.out.println("What is the date of the entry?");
System.out.println("Please enter the month: ");
month=input.nextLine();
System.out.println("Please enter the day: ");
day=input.nextInt();
System.out.println("Please enter the year: ");
year=input.nextInt();

System.out.println("\nBlog Entry:");
BlogEntry entry1= new BlogEntry(name,entry,month,day,year);
BlogEntry entry2= new BlogEntry(name,entry,month,day,year);
entry2.setSummary(entry);
System.out.println("\nThe summary of this entry is "+entry2.getSummary);
  
  
  
  
}

}

.

.

.

.

the error is occuring for my getSummary and setSummary

BlogEntry.java:47: error: '(' expected private void String setSummary() ^

BlogEntry.java:67: error: invalid method declaration; return type required public getSummary() ^

2 errors

In: Computer Science