Questions
Write a program that has a function (named getNumStats()) that will return a string that has...

Write a program that has a function (named getNumStats()) that will return a string that has stats on the number entered.

The prototype is:

string getNumStats(double);

The stats are:

            Is the number an integer or a double?

            The polarity (is it positive or negative; 0 counts as positive)

            The parity (is it odd or even)

            Is it a prime number? (for this program, 1 is considered a prime number)

For example, if the following lines of code are executed

double dNum = 14.06;

string test = getNumStats(dNum)

cout << test << endl;

The output that appears on the screen will be:

14.06 is a double

It is positive

It does not have parity

It is not a prime number

Another run is:

double dNum = -27.371;

string test = getNumStats(dNum)

cout << test << endl;

The output that appears on the screen will be:

-23.371 is a double

It is negative

It does not have parity

It is not a prime number

Note: your first line of output may or may not show trailing zeros. You may add that feature to always show zeros (even if the number is an integer)

In: Computer Science

How can I analyze "Enron Dataset" using ONLY "Naive Bayes model" or "SVM(Support Vector Machine) model"...

How can I analyze "Enron Dataset" using ONLY "Naive Bayes model" or "SVM(Support Vector Machine) model" or "Decision Trees model" or  "Random Forest model" or "K Nearest Neighbors model". And for what purpose the result can be used? Please give me some rough ideas and methods. No need to right down the Python codes.

In: Computer Science

Explain the similarities and differences between Drop (a table), Truncate (the data), and Delete (the data).

Explain the similarities and differences between Drop (a table), Truncate (the data), and Delete (the data).

In: Computer Science

I created a shoppingcart program but I'm getting a few compilation failed errors: 1) Tests that...

I created a shoppingcart program but I'm getting a few compilation failed errors:

1) Tests that ItemToPurchase("Bottled Water", "Deer Park, 12 oz.", 1, 10) correctly initializes item compilation failed

2) Tests default constructor and accessors for ShoppingCart Compilation failed

3)Tests ShoppingCart("John Doe", "February 1, 2016") correctly initializes cart Compilation failed

4) Tests that getNumItemsInCart() returns 6 (ShoppingCart) compilation failed

5) Test that getCostOfCart() returns 9 (ShoppingCart) compilation failed

Complete program:

itemtopurchase.java

public class ItemToPurchase {
// instance variables
private String itemName;
private String itemDescription;
private int itemPrice;
private int itemQuantity;
// default constructor
public ItemToPurchase() {
this.itemName = "none";
this.itemDescription = "none";
this.itemPrice = 0;
this.itemQuantity = 0;
}
public ItemToPurchase(String itemName, int itemPrice, int itemQuantity,String itemDescription) {
this.itemName = itemName;
this.itemDescription = itemDescription;
this.itemPrice = itemPrice;
this.itemQuantity = itemQuantity;
}
// method to set name of the item
public void setName(String name) {
itemName = name;
}
// method to set price of the item
public void setPrice(int price) {
itemPrice = price;
}
// method to set quantity of the item
public void setQuantity(int quantity) {
itemQuantity = quantity;
}
public void setDescription(String description) {
itemDescription = description;
}
// method to get name of the item
public String getName() {
return itemName;
}
// method to get price of the item
public int getPrice() {
return itemPrice;
}
// method to get quantity of the item
public int getQuantity() {
return itemQuantity;
}
public String getDescription() {
return itemDescription;
}
public void printItemPurchase() {
System.out.println(itemName + " " + itemQuantity + " @ $" + itemPrice + " = $" + (itemPrice * itemQuantity));
}
public void printItemDescription() {

System.out.println(itemName+": "+itemDescription);
}
}

shoppingcart.java

import java.util.ArrayList;

public class ShoppingCart {

//instance variables
private String customerName;
private String currentDate;
private ArrayList<ItemToPurchase> cartItems = new ArrayList<ItemToPurchase>();

//Default constructor
public ShoppingCart() {
customerName = "";
currentDate = "";
}

//parameterized constructor
public ShoppingCart(String customerName, String currentDate) {
this.customerName = customerName;
this.currentDate = currentDate;
}

//getter methods
public String getCustomerName() {
return customerName;
}

public String getCurrentDate() {
return currentDate;
}

//add items
public void addItem(ItemToPurchase item) {
cartItems.add(item);
}

//remove item
public void removeItem(String name) {
for (ItemToPurchase i : cartItems) {
if (i.getName().equalsIgnoreCase(name)) {
cartItems.remove(i);
return;
}
}

System.out.println("Item not found in cart");
}

//modify the item
public void modifyItem(ItemToPurchase item) {
for (int i = 0; i < cartItems.size(); i++) {
if (cartItems.get(i).getName().equalsIgnoreCase(item.getName())) {
if (!item.getDescription().equals("none") && !(item.getPrice() == 0) && !(item.getQuantity() == 0)) {
cartItems.add(i, item);
return;
}
}
}

System.out.println("Item not found in cart. Nothing modified");

}

//get total number of items in the cart
public int getNumItemsIncart() {
int sum = 0;
for (ItemToPurchase i : cartItems) {
sum += i.getQuantity();
}
return sum;
}

//get total cost of items in the cart
public int getCostOfcart() {
int sum = 0;
for (ItemToPurchase i : cartItems) {
sum += i.getPrice();
}
return sum;
}

//printing total of each items
public void printTotal() {
System.out.println(customerName + "'s Shopping Cart - " + currentDate);
if (cartItems.isEmpty()) {
System.out.println("Shopping Cart is Empty");
return;
}

System.out.println("Number of Items: " + cartItems.size());
System.out.println();
for (ItemToPurchase i : cartItems) {
i.printItemPurchase();
}
System.out.println();
System.out.println("Total: $" + getCostOfcart());
}

//printing description of all items
public void printDescription() {
System.out.println(customerName + "'s Shopping Cart - " + currentDate);
System.out.println();
if (cartItems.isEmpty()) {
System.out.println("Shopping Cart is Empty");
return;
}
System.out.println("Item Descriptions: ");
for (ItemToPurchase i : cartItems) {
i.printItemDescription();
}
}
}

shoppingcartmanager.java

import java.util.Scanner;

public class ShoppingCartManager {

// method to add an item in the cart
public static void addCartItem(Scanner scan, ShoppingCart cart) {
String itemName, itemDescription;
int itemPrice, itemQuantity;
System.out.println("ADD ITEM TO CART");
System.out.print("Enter the item name : ");
itemName = scan.nextLine();
System.out.print("Enter the item description : ");
itemDescription = scan.nextLine();
System.out.print("Enter the item price : ");
itemPrice = scan.nextInt();
System.out.print("Enter the item quantity : ");
itemQuantity = scan.nextInt();
scan.nextLine();

cart.addItem(new ItemToPurchase(itemName, itemPrice, itemQuantity, itemDescription));

}

// method to remove an item from the cart
public static void removeCartItem(Scanner scan, ShoppingCart cart) {
String itemName;
System.out.println("REMOVE ITEM FROM CART");
System.out.print("Enter the name of item to remove : ");
itemName = scan.nextLine();

cart.removeItem(itemName);
}

// method to change quantity of the cart
public static void changeItemQuantity(Scanner scan, ShoppingCart cart) {
String itemName;
int itemQuantity;
System.out.println("CHANGE ITEM QUANTITY");
System.out.print("Enter the item name : ");
itemName = scan.nextLine();
System.out.print("Enter the new quantity : ");
itemQuantity = scan.nextInt();
scan.nextLine();
cart.modifyItem(new ItemToPurchase(itemName, 0, itemQuantity, "none"));
}

// method to display menu choices and perform the operations on the cart until
// the user quits
public static void printMenu(ShoppingCart cart) {
String choice;
Scanner scan = new Scanner(System.in);
do {
System.out.println("\nMENU");
System.out.println("a - Add item to cart");
System.out.println("d - Remove item from cart");
System.out.println("c - Change item quantity");
System.out.println("i - Output items' description");
System.out.println("o - Output shopping cart");
System.out.println("q - Quit");
System.out.print("\nChoose an option : ");
choice = scan.nextLine();

if (choice.equalsIgnoreCase("a")) {
addCartItem(scan, cart);
} else if (choice.equalsIgnoreCase("d")) {
removeCartItem(scan, cart);
} else if (choice.equalsIgnoreCase("c")) {
changeItemQuantity(scan, cart);
} else if (choice.equalsIgnoreCase("o")) {
System.out.println("OUTPUT SHOPPING CART");
cart.printTotal();
} else if (choice.equalsIgnoreCase("i")) {
System.out.println("OUTPUT ITEMS' DESCRIPTION");
cart.printDescription();
} else if (!choice.equalsIgnoreCase("q"))
System.out.println("Invalid choice");

} while (!choice.equalsIgnoreCase("q"));

}

public static void main(String args[]) {
Scanner sc = new Scanner(System.in);

// taking user input
System.out.println("Enter Customer's Name:");
String name = sc.nextLine();
System.out.println("Enter Today's Date:");
String date = sc.nextLine();

// printing user input
System.out.println();
System.out.println("Customer Name: " + name);
System.out.println("Today's Date: " + date);

ShoppingCart cart = new ShoppingCart(name, date);// created shopping cart object
printMenu(cart);
}
}

In: Computer Science

How could I implement the contain and min method for a tree in this code. import...

How could I implement the contain and min method for a tree in this code.


import java.util.List;
import edu.princeton.cs.algs4.*;


class ProgrammingAssignment1 {

    //////////////////// EXERCICE 1: TWO THREE TREES

    static public <Key extends Comparable<Key>>
    int size (NakedTree<Key> tree) {
      if (tree == null)
        return 0;
      int val = tree.getNKeys ();
      for (int i = 0; i <= tree.getNKeys (); ++i)
        val += size (tree.getChild (i));
      return val;
    }

    //////// EXERCICE 1.1: contains AND min

    static public <Key extends Comparable<Key>>
    boolean contains (NakedTree<Key> tree, Key key) {

       
    }

In: Computer Science

Hello, I have a problem with understanding this line. forEach(value.split("<br>"), line, line.trim()).slice(-3).join("\n") This line is for...

Hello, I have a problem with understanding this line.

forEach(value.split("<br>"), line, line.trim()).slice(-3).join("\n")

This line is for the open refine program. Could you tell me what this line is trying to do? I have no idea what this is for...

For your information, this line appeared when professor was talking about 'Fetching and Parsing HTML'..

Thank you for answering my question and have a good day!

p.s. My professor told us to insert that line in the expression box and try to figure out what this expression means... As I'm not majoring in CS, it's too difficult for me to understand..;(

In: Computer Science

Discuss the open-source tools in general. What are the advantages versus disadvantages? What is the life-long...

Discuss the open-source tools in general. What are the advantages versus disadvantages? What is the life-long learning lesson you think you are able to acquire with this type of assignment? Discuss ethical and global issues.

In: Computer Science

1) Consider any recent acquisition by Facebook. Why do you think Facebook purchased the company? Suggest...

1) Consider any recent acquisition by Facebook. Why do you think Facebook purchased the company? Suggest ways in which the app has been monetized
2) With the emergence and now certaintly of online commerce, are store fronts still relevant in retail? If so, what role(s) do they play?

In: Computer Science

#include <stdio.h> int main(void) { int input = -1; double average = 0.0;    /* Use...

#include <stdio.h>

int main(void) {
int input = -1;
double average = 0.0;
  
/* Use this for your input */
scanf("%d", &input);
  
/* This is the only output you need */
printf("%.1lf", average);
return 0;
}

Please write a C coding program (make it simple coding)  that find the average of sequence integer. when user enter integers, once at a time. Also, If the user enters 0 (zero), the code will calculates the average and then prints it, and then exits.

In: Computer Science

________ means that IT capacity can be easily scaled up or down as needed, which essentially...

  1. ________ means that IT capacity can be easily scaled up or down as needed, which essentially requires cloud computing.
  1. agility
  2. flexibility
  3. responsiveness
  4. IT consumerization
  1. ________ is the migration of privately-owned mobile devices into enterprise IT environments.
  1. agility
  2. flexibility
  3. responsiveness
  4. IT consumerization
  1. Influential industry leaders cite ____________ as their largest business challenge in sustaining a competitive edge.
  1. keeping up with technology
  1. employee performance
  2. economic climate
  3. new competition
  1. A website or app that is scaled to be viewed from a computer, tablet, or smartphone is said to be_________.
  1. responsive
  2. flexible
  3. agile
  4. competitive
  1. IT agility, flexibility, and mobility are tightly interrelated and primarily dependent on:
  1. An organization’s IT infrastructure and architecture
  2. The IT division’s strategic hiring and training practices
  3. IT’s integration with production and accounting units
  4. Strategic alignment between IT budget and company mission statement
  1. Matt is using his own tablet for work purposes, which is an example of a trend called _____________.
  1. Mixed use IT
  2. Employer IT cost shifting
  3. IT consumerization
  4. BYOM
  1. Using a combination of mobile and database technology, Pizza House keeps records of the pizza preferences of all its customers. When Sam orders from Pizza House, he only says “send me the usual” when he calls in his order; and hangs up.   Accessing the database, the Pizza House worker knows his address, his usual order, and what credit card to bill. The streamlined ordering and fulfillment efficiency give the Pizza House __________.
  1. A strategic plan
  2. A strategic model
  3. A competitive advantage
  4. A sustainably business edge
  1. iTunes was a significant breakthrough that forever changed the music industry and the first representation of Apple's ________.
  1. IT consumerization
  2. Sustainable competitive advantage
  3. Incompatibility with Windows
  4. future outside its traditional computing product line
  1. How many times a day does the average American check their smartphone?
  1. 24
  2. 59
  3. 46
  4. 99
  1. IT job growth is estimated at ________ from 2014 to 2024, according to the U.S. Department of Labor.
  1. 12%
  2. 5%
  3. 33%
  4. Over 50%
  1. _____________ evaluate the newest and most innovative technologies and determine how they can be applied for competitive advantage. They develop technical standards, deploy technology, and supervise workers who deal with the daily IT issues of the firm.
  1. Project Managers
  2. Chief Technology Officers
  3. CEOs
  4. CFOs
  1. _____________ develop requirements, budgets, and schedules for their firm’s information technology projects. They coordinate such projects from development through implementation, working with their organization’s IT workers, as well as clients, vendors, and consultants.
  1. Project Managers
  2. Chief Technology Officers
  3. CEOs
  4. CFOs

In: Computer Science

I need to create a servlet that takes in an input that will do the following...

I need to create a servlet that takes in an input that will do the following calculations.

  1. If the input number is a prime, just output a message showing that it is a prime;
  2. If the input number is not a prime and it is an odd integer, write it as a product of two smaller odd integers;
  3. If the input number is not a prime and it is an even integer, first extract the largest power of 2, then for the remaining odd number, try to factorize it if you can. For your output, you give the power of 2 as one number and one more factor if this factor is a prime, or two more factors if you can still factorize the odd number after extracting the power of 2.

In: Computer Science

When you buy a new computer what would you do to harden it

When you buy a new computer what would you do to harden it

In: Computer Science

Provide two classification scenarios where you can use classification tree models but not logistic regression models....

Provide two classification scenarios where you can use classification tree models but not logistic regression models. For each problem, identify a target variable and four possible predictor variables.

In: Computer Science

Part II: Programming Questions NOTE: CODING LANGUAGE IS C# PQ1. How would you declare the following...

Part II: Programming Questions

NOTE: CODING LANGUAGE IS C#

PQ1. How would you declare the following scalar and non-scalar (vector) variables?

  1. counter, an integer
  2. sum, a decimal number
  3. average, a decimal number
  4. grades, an array of 32 decimal numbers

PQ2.

  1. How would you initialize the array above with numbers between 0.0 and 4.0 representing the grades of all courses a senior has received in the four years of college?
  2. Instead of initializing the array above, how would you, in a loop, accept input from the user for the 32 grades?

PQ3.

  1. How would you calculate the sum of all the grades in the array above?
  2. How would you average the sum above?

PQ4. The algorithm for checking if a number is a prime is to check if it is divisible by any number less than itself other than 1. (Divisibility implies that if you use the modulus operator, %, the result will be 0). Write a function to check if a number is a prime.

In: Computer Science

Write a C program to implement Jacobi iterative method for sovling a system of linear equations....

Write a C program to implement Jacobi iterative method for sovling a system of linear equations. Use the skeleton code.

skeleton code:

/* 
   CS288 HOMEWORK 8
   Your program will take in two command-line parameters: n and error
   command: jacobi 5 0.0001
   command: jacobi 10 0.000001
 */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <math.h>

#define N 100
#define MAX_ITER 10000

int jacobi();
void init();
int convergence();
void srand();
void print_vector();
void print_equation();

float a[N][N], b[N];
float x[N], buf[N];
int n;
float error;

int main(int argc, char **argv){
  int n_iter;                   /* number of iterations */
  n = atoi(argv[1]);
  error = atof(argv[2]);

  init();                  /* initalize a, x0 and b - DO not change */
  n_iter = jacobi();

  return 0;
}

int jacobi(){
  int i,j,k;
  float sum;
  // ...
  // ...
  // ...
  return k;
}

// returns 1 if converged else 0
int convergence(int iter){
  int i,j,k,flag=1;
  // ...
  // ...
  // ...

  return flag;
}

// Try not to change this. Use it as is.
void init(char **argv){
  int i,j,k,flag=0;
  float sum;
  int seed = time(0) % 100;     /* seconds since 1/1/1970 */

  srand(seed);
  for (i=0;i<n;i++) {
    for (j=0;j<n;j++) {
      a[i][j] = rand() & 0x7;
      if (rand() & 0x1) a[i][j] = -a[i][j];
    }
    sum = 0;
    for (j=0;j<n;j++) if(i!=j) sum = sum + abs(a[i][j]);
    if (a[i][i] < sum) a[i][i] = sum + a[i][i];
  }

  for (i=0;i<n;i++) x[i]=1;

  srand(seed);
  for (i=0;i<n;i++){
    b[i]=rand() & 0x7;
    if (rand() & 0x1) b[i] = -b[i];
  }

  print_equation();

}

void print_equation(){
  int i,j;

  printf("A*x=b\n");
  for (i=0;i<n;i++) {
    for (j=0;j<n;j++) printf("%2d ",(int)(a[i][j]));
    printf(" * x%d = %d\n",i,(int)(b[i]));
  }
  printf("\n");
}

void print_vector(float *l){
  int i;
  for (i=0; i<n; i++) printf("%.6f ",l[i]);
  printf("\n");
}

// end of file

In: Computer Science