Questions
What does it mean to say that problem is a function problem? is a decision problem?...

What does it mean to say that problem

is a function problem?

is a decision problem?

is in class NP?

is in class P?

In: Computer Science

Major interviewed (IT specialist) Conducting an informational interview with a professional currently working in a career...

Major interviewed (IT specialist)

Conducting an informational interview with a professional currently working in a career field that interests you. You are not permitted to interview parents or other close family members, but you are welcome to interview family friends/colleagues. Interviews can be done either over-the-phone or in-person, and they should last approximately 20-30 minutes. You are encouraged to consider the questions below, but you will likely need to include additional questions of your own to gather enough information for the assignment.

  • How long have you worked in this field? Where else have you worked? Did you make a career change at any point in your life?
  • What is your educational background? What did you do in college to prepare for the professional world?
  • How did you become interested in this field?
  • What is your current position title, and what do you do in your role? What are the typical work hours, responsibilities, etc.?
  • What skills, abilities, and personal attributes are essential to success in this field?
  • What is something you encountered that you didn't expect when pursuing this career path?
  • What advice would you give your younger self?

Once you have conducted your interview, you will complete a 2-page report (double-spaced, Times New Roman 12 pt. font, and 1-inch margins) that includes two parts:

  • A breakdown of the interview, itself. This can either be in Q&A format or paragraph form. (1-page minimum)
  • Your thoughts following the interview. What did you learn? What piece(s) of information will stick with you the most? Does their position/career path still interest you? Do you have any concerns about following a similar path?

In: Computer Science

For my class the first step of our homework was to make a project known as...

For my class the first step of our homework was to make a project known as "TriangleTester" to input the lengths of a triangle and have them calculate the area and perimeter. Now the 2nd step is to split the project into two classes, where "TriangleTester" asks for the user's input and "Triangle" uses a getInput() method to recieve the input and uses recursion to get the input and do the calculations for the area and perimeter.

This is for java software

Here is the first step code.

import java.util.Scanner;
public class TriangleTester {
public static void main(String[] args)
{
double side1,side2,side3;
Scanner input = new Scanner(System.in);

System.out.print("Enter lengths of sides of the triangle: ");

side1 = input.nextDouble();

side2 = input.nextDouble();

side3 = input.nextDouble();


if ((checkValidity(side1, side2, side3))==1) {

double perimeter = side1 + side2 + side3;
double area = 0;
double s = (side1 + side2 + side3)/2;
  
area = Math.sqrt(s*(s - side1)*(s - side2)*(s - side3));

System.out.println("The perimeter of the triangle is " + perimeter

+ ".");
System.out.println("The Area of the triangle is " + area + ".");

} else {

System.out.println("Those sides do not specify a valid triangle.");

}

input.close();
}
// Function to calculate for validity

private static int checkValidity(double a, double b, double c)
{

// check condition

if (a + b <= c || a + c <= b || b + c <= a)

return 0;

else

return 1;
}

}

In: Computer Science

Create a Java class file for an Account class. In the File menu select New File......

  1. Create a Java class file for an Account class.
    1. In the File menu select New File...
    2. Under Categories: make sure that Java is selected.
    3. Under File Types: make sure that Java Class is selected.
    4. Click Next.
    5. For Class Name: type Account.
    6. For Package: select csci1011.lab8.
    7. Click Finish.
    8. A text editor window should pop up with the following source code (except with your actual name):
    1. csci1011.lab8;

      /**
      *
      * @author Your Name
      */
      public class Account {

      }
  1. Implement the Account class.
    1. Add a public enum called ACCOUNT_TYPE with two values CHECKING, SAVING
    2. Add the following private instance variables to the Account class:
      • An instance variable called aType of type Enum ACCOUNT_TYPE.
      • An instance variable called accountOwner of type String.
      • An instance variable called interestRate of type double.
      • An instance variable called balance of type double
    3. Add getters and setters for the four instance variables of item (b) to the Account class:
    4. Add the following methods to the Account class:
      • A void method called initialize that takes a parameter of type ACCOUNT_TYPE, a String, two doubles and uses those arguments to set the values of the accountType, accountOwner, interestRate, and balance instance variables.
      • A void method called display that displays the account information.
      • A void method called deposit with one parameter of double that adds the given parameter to the balance instance variable.
      • A void method called withdraw with one parameter of double that deduct the given parameter from the balance instance variable. This method prints an error message when the given parameter is greater than the balance. In this case no money should be withdrawn from the account.
  • In the main method of your main class, create two Account objects and perform the following:
    • Initialize the first account objects with SAVING as the accountType and other parameters of your own choice.
    • Initialize the first account objects with CHECKING as the accountType and other parameters of your own choice.
    • Display both accounts.
    • Deposit $200 from the first account
    • Withdraw $500 from the second account
  • Display both accounts.
  • Run the main program to see if the tests were successful.
    • Here is a sample output of the program.

Account Type: SAVING

Account Owner: Customer B

Interest Rate: 1.1

Balance: 500.0

Account Type: CHECKING

Account Owner: Customer A

Interest Rate: 1.2

Balance: 200.0

Cannot withdraw more than account balance

Account Type: SAVING

Account Owner: Customer B

Interest Rate: 1.1

Balance: 700.0

Account Type: CHECKING

Account Owner: Customer A

Interest Rate: 1.2

Balance: 200.0

In: Computer Science

Write a java program that adds up the squares and adds up the cubes of integers...

Write a java program that adds up the squares and adds up the cubes of integers from 1 to N, where N is entered by the user:

Upper Limit:

5

The sum of Squares is 55

The sum of Cubes is 225

Do this by using just one loop that generates the integers. DO NOT USE ANY FORMULAS.

In: Computer Science

Data Structures in Java In the following Singly Linked List implementation, add the following methods, and...

Data Structures in Java

In the following Singly Linked List implementation, add the following methods, and write test cases in another java file to make sure these methods work.

- Write a private method addAfter(int k, Item item) that takes two arguments, an int argument k and a data item, and inserts the item into the list after the K-th list item.

- Write a method removeAfter(Node node) that takes a linked-list Node as an argument and removes the node following the given node.

- Write a method deleteKth that takes an int argument k and deletes the kth element in a linked list, if it exists.

Notice: Please do not modify the other methods in SLList class, just add the methods above.

public class SLList {
   private Node first;
   private Node last;
   private int n; // size of the list

   // helper node class
   private class Node {
      Item item;
      Node next;
   }

   // constructor: initializes an empty list
   public SLList() {
      first = last = null;
      n = 0;
   }

   public boolean isEmpty() {
      return first == null;
   }

   // return the size of the list
   public int size() {
      return n;
   }

   // insert an item at the front of the list
   public void addFirst(Item item) {
      if (isEmpty()) { // first & last refer to the same node
         first = last = new Node();
         first.item = last.item = item;
      } else {  //first refers to the new node
         Node oldFirst = first;
         first = new Node();
         first.item = item;
         first.next = oldFirst;
      }
      n++; // increment size after insertion
   }

   // insert item at the end of the list
   public void addLast(Item item) {
      if (isEmpty()) { // first & last refer to the same node
         first = last = new Node();
         first.item = last.item = item;
      } else { // last.next refers to the new node
         last = last.next = new Node();
         last.item = item;
      }
      n++; // increment size after insertion
   }

   // remove & return the first item in the list
   public Item removeFirst() {
      if (isEmpty()) {
         throw new RuntimeException("Empty List");
      }
      Item removedItem = first.item;  // retrieve the data item being removed
      if (first == last) {             // if there's only one node in the list
         // update both first & last references
         first = last = null;
      }
      else   { // otherwise, update first only
         first = first.next;
      }
      n--; // decrement size after removal
      return removedItem;
   }


   // remove & return the last item in the list
   public Item removeLast() {
      if (isEmpty()) throw new RuntimeException("empty list");
      Item removedItem = last.item;   // retrieve the data item being removed
      if (first == last) { // if there's only one node in the list,
         // update both first & last references
         first = last = null;
      }
      else {  // iterate through the list to locate the last node
         Node current = first;
         while (current.next != last) {
            current = current.next;
         }
         last = current;
         current.next = null;
         // ...  current is the new last node
         //

      } // end else
      n--; // decrement size after removal
      return removedItem;
   }

   // A String representation of this list, so that clients can print it
   // (There's no need to change it, but you can, if you'd like.)
   @Override
   public String toString() {
      StringBuilder s = new StringBuilder();
      Node current = first;
      while (current != null) {
         s.append(current.item + " -> ");
         // s.append(current.item + " ");
         current = current.next;
      }
      s.append("null");
      //s.append("\n");
      return s.toString();
   }
   private Node getNode(int index) {
      Node current = first;
      for (int i = 0; i < index; i++) {
         current = current.next;
      }
      return current;
   }

   public Item get(int index) {
      if (index < 0 || index >= n) {
         throw new IndexOutOfBoundsException("out of bounds");
      }
   return getNode(index).item;
   }

   public Item set(int index, Item item) {
      if (index < 0 || index >= n) {
         throw new IndexOutOfBoundsException("out of bounds");
      }
      Node target = getNode(index);
      Item oldItem = target.item;
      target.item = item;
      return oldItem;
   }

}

In: Computer Science

public class Book{     public String title;     public String author;     public int year;    ...

public class Book{

    public String title;
    public String author;
    public int year;
    public String publisher;
    public double cost;
      
    public Book(String title,String author,int year,String publisher,double cost){
       this.title=title;
        this.author=author;
        this.year=year;
        this.publisher=publisher;
        this.cost=cost;
    }

    public String getTitle(){
        return title;
    }
  
     public String getAuthor(){
        return author;
    }
    public int getYear(){
        return year;
    }
    public String getPublisher(){
        return publisher;
    }
    public double getCost(){
        return cost;
    }
    public String toString(){
        return "Book Details: " + title + ", " + author + ", " + year + ", " + publisher + ", " + cost;
    }
}

public interface MyQueue {
   public abstract boolean enQueue(int v);
   public abstract int deQueue();
   public abstract boolean isFull();
   public abstract boolean isEmpty();
   public abstract int size();
   public abstract int peek();
}

public interface MyStack {
   public abstract boolean isEmpty();
   public abstract boolean isFull();
   public abstract boolean push(T v);
   public abstract T pop();
   public abstract T peek();
  
}

public class MyQueueImpl implements MyQueue {
   private int capacity;
   private int front;
   private int rear;
   private int[] arr;
   public MyQueueImpl(int capacity){
       this.capacity = capacity;
       this.front = 0;
       this.rear = -1;
       this.arr = new int[this.capacity];
   }
   @Override
   public boolean enQueue(int v) {      
           if(this.rear == this.capacity - 1) {
               //Perform shift
               int tempSize = this.size();
               for(int i=0; i < tempSize; i++) {
                   arr[i] = arr[front];
                   front++;
               }
               front = 0;
               rear = tempSize - 1;
           }
           this.rear ++;
           arr[rear] = v;
           return true;
   }
   @Override
   public int deQueue() {
       return arr[front++];
      
   }
   public String toString() {
       String content = "Queue :: ";
      
       for(int i=front; i<= rear; i++) {
           content += "\n" + arr[i];
       }
       return content;
   }
   @Override
   public boolean isFull() {
       return (this.size() == this.capacity);
   }
   @Override
   public int size() {
       return rear - front + 1;
   }
   @Override
   public boolean isEmpty() {
       // TODO Auto-generated method stub
       return (this.size() == 0);
   }
   @Override
   public int peek() {
       // TODO Auto-generated method stub
       return this.arr[this.front];
   }
}

import java.lang.reflect.Array;
public class MyStackImpl implements MyStack {
   // TODO write your code here
  
  
   @Override
   public boolean isEmpty() {
       // TODO Auto-generated method stub
       return false;
   }

   @Override
   public boolean isFull() {
       // TODO Auto-generated method stub
       return false;
   }
  
   @Override
   public boolean push(T v) {
       // TODO write your code here
      
       return true;
   }

   @Override
   public T pop() {
       // TODO write your code here
      
       return null;
      
   }
  
   public String toString() {
       // TODO write your code here
      
      
      
       return "";
   }

   @Override
   public T peek() {
       // TODO Auto-generated method stub
       return null;
   }

}

make test classs   

write your code here
        Create a queue object.
        insert 5 Books in the Queue
        Create a stack object.
        Use the stack to reverse order of the elements in the queue.

In: Computer Science

Using Matlab do the following Write a program that will accept a number from the user...

Using Matlab do the following

Write a program that will accept a number from the user and:

  1. Check if the number between 50 and 100both inclusive. If yes print a comment. If not print a warning.
  2. The program sums the inserted values
  3. This process continues until the user inserts the number 999 . At this point the program quits and prints the result of (2)

In: Computer Science

Java Question: What is exception propagation? Give an example of a class that contains at least...

Java Question:

What is exception propagation? Give an example of a class that contains at least two methods, in which one method calls another. Ensure that the subordinate method will call a predefined Java method that can throw a checked exception. The subordinate method should not catch the exception. Explain how exception propagation will occur in your example.

In: Computer Science

Given: struct Person { int id;     int stats[3] }; Which is the correct way to...

Given:

struct Person
{
int id;
    int stats[3]
};

Which is the correct way to initialise an array of Persons?

1.

struct Person persons[2] = {7, "8,9,3", 8, "2,5,9"};

2.

struct Person persons[2] = "7, {8,9,3}, 8, {2,5,9}";

3.

struct Person persons[2] = "7, "8,9,3", 8, "2,5,9";

4.

struct Person persons[2] = {7, {8,9,3}, 8, {2,5,9}};

Which of the following is not a primitive type in the C language?

1.

string

2.

int

3.

long

4.

char

Given:

struct Person
{
int id;
    int stats[3]
};

Which is the correct way to access the 2nd member of stats in an instance named John?

1.

John.stats[2]

2.

John->stats[2]

3.

John->stats[1]

4.

John.stats[1]

Given:

struct Person
{
int id;
    int stats[3]
};

Which is the correct way to initialise an instance of Person?

1.

struct Person John = "5,{4,5,6}";

2.

struct Person John = {"5", "4,5,6"};

3.

struct Person John = {5, {4,5,6}};

4.

Person John = {5, {4,5,6}};

Instead of using parallel arrays with a key and value array, we can create a derived type with members that represent the key – value pair.

True

False

A derived type is a collection of other types.

True

False

Given:

struct Person
{
int id;
    int stats[3]
};

*John.stats[0]; will retrieve the fist element of stats in a Person instance named John.

True

False

What is the key word used to create a user defined (derived) type in the C language?

1.

class

2.

object

3.

collection

4.

struct

In: Computer Science

Python Text processing/masks Write a function called unique words that takes a phrase as an input...

Python Text processing/masks

Write a function called unique words that takes a phrase as an input string and returns a list of the unique words found in that phrase. The words should be listed in alphabetical order.

Scriipt for ATOM or REPL, NOT PYTHON SHELL

In: Computer Science

#include <iostream> #include <string> #include <iomanip> #include <fstream> using namespace std; struct Product {    string...

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>

using namespace std;
struct Product
{
   string itemname;
   int id;
   string itemcolor;
   double cost;
};

void fillProduct(Product[10], int& );//read data from a file and store in an array
void writeProduct(Product[10], int);//write the array into a file
void writeBinary(Product[10], int);//write the array into a file in binary mode
void printbinary(Product[10], int);//read data from the binary file and print


int main()
{
   Product myList[10];
   int numItems = 0;
   fillProduct(myList, numItems);
   writeProduct(myList, numItems);
   writeBinary(myList, numItems);
   printbinary(myList, numItems);
   return 0;
}


void fillProduct(Product myList[10], int& numItems)
{
   ifstream indata;
   indata.open("lab6data.txt");
   if (!indata)
   {
       cout << "Error opening file. Program aborting.\n";
   }
   else
   {
       string tname;
       getline(indata, tname);
       while (!indata.eof())
       {
           myList[numItems].itemname = tname;
           indata >> myList[numItems].id;
           indata.ignore();
           getline(indata, myList[numItems].itemcolor);
           indata >> myList[numItems].cost;
           indata.ignore();
           numItems++;
           getline(indata, tname);
          
       } // END WHILE
   }
   indata.close();
}

void writeProduct(Product myList[10], int numItems)
{
   ofstream outdata;
   outdata.open("output.txt");
   if (!outdata)
   {
       cout << "Error opening file. Program aborting.\n";
   }
   else
   {
       outdata << left;
       outdata << setw(15) << "Item Name"
           << setw(15) << "ID"
           << setw(15) << "Color"
           << setw(15) << "Cost" << endl;
       outdata << setw(15) << "---------"
           << setw(15) << "--"
           << setw(15) << "-----"
           << setw(15) << "----" << endl;
       for (int k = 0; k < numItems; k++)
       {
           outdata << setw(15) << myList[k].itemname
                   << setw(15) << myList[k].id
                   << setw(15) << myList[k].itemcolor
                   << setw(15) << myList[k].cost << endl;
       }
   }
   outdata.close();
}

void writeBinary(Product myList[10], int numItems)
{
   ofstream outbinary;
   outbinary.open("binary.dat", ios::binary);
   if (!outbinary)
   {
       cout << "Error opening file. Program aborting.\n";
   }
   else
   {
       for (int k = 0; k < numItems; k++)
       {
           //TODO Write a single statement below that writes data in myList[k] into binary.dat
      
       }

   }
   outbinary.close();
}


void printbinary(Product myList[10],int numItems) {
   ifstream inbinary;
   inbinary.open("binary.dat", ios::binary);
   if (!inbinary)
   {
       cout << "Error opening file. Program aborting.\n";
   }
   else
   {
       cout << left;
       cout<< setw(15) << "Item Name"
           << setw(15) << "ID"
           << setw(15) << "Color"
           << setw(15) << "Cost" << endl;
       cout << setw(15) << "---------"
           << setw(15) << "--"
           << setw(15) << "-----"
           << setw(15) << "----" << endl;

       for (int k = 0; k < numItems; k++)
       {
           //TODO Write a single statement below that read data from binary.dat and store them in myList[k].
          

           //TODO Print the data stored in myList[k], and the output should have the same format as the example in the instruction.
          
       }
   }
   inbinary.close();

}

In: Computer Science

for each malware type ( Trojan Horse , Worm , Ransomware , spyware, logic bomb) find...


for each malware type ( Trojan Horse , Worm , Ransomware , spyware, logic bomb) find a real world example the past 10 years and describe it (name, exploit, damage)


In: Computer Science

Stack Class //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Queue Class public class Stack { private java.util.ArrayList pool = new java.util.ArrayList(); pu

Stack Class

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Queue Class

public class Stack {
private java.util.ArrayList pool = new java.util.ArrayList();
public Stack() {
}
  
public Stack(int n) {
pool.ensureCapacity(n);
}
  
public void clear() {
pool.clear();
}
  
public boolean isEmpty() {
return pool.isEmpty();
}
  
public Object topEl() {
if (isEmpty())
throw new java.util.EmptyStackException();
return pool.get(pool.size()-1);
}
  
public Object pop() {
if (isEmpty())
throw new java.util.EmptyStackException();
return pool.remove(pool.size()-1);
}
  
public void push(Object el) {
pool.add(el);
}
  
public String toString() {
return pool.toString();
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public class Queue {
private java.util.LinkedList list = new java.util.LinkedList();
  
public Queue() {
}
  
public void clear() {
list.clear();
}
  
public boolean isEmpty() {
return list.isEmpty();
}
  
public Object firstEl() {
return list.getFirst();
}
  
public Object dequeue() {
return list.removeFirst();
}
  
public void enqueue(Object el) {
list.add(el);
}
  
public String toString() {
return list.toString();
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

MAIN

import java.util.*;

public class StacksTest {
   public static void main(String[] args) {
       Stack s = new Stack();
       s.push(new Integer(3));
       s.push(new Integer(5));
       s.push(new String("hi"));
       while(!s.isEmpty()) {
           System.out.print(s.pop() + " ");
       }
      
       s.clear(); //Empty the contents of the stack
      
       System.out.println("\nHere's how I reverse a string: ");
       Scanner k = new Scanner(System.in);
       System.out.print("Enter a string> ");
       String input = k.nextLine();
      
       for(int i = 0; i < input.length(); i++)
           s.push(input.charAt(i) + "");
          
       System.out.println("The reversed string is: ");
       while(!s.isEmpty()) {
           System.out.print(s.pop());
       }
      
       System.out.println();
      
   }
}

///////////////////////////////////////////////////////////////////Lab Exercises.//////////////////////////////////////////////////////////////////////

Lab Exercises.

2. Write a method (in the class StackTest) public static boolean isPalindrome(String input) that checks if a given string is a palindrome using a stack. Test your method using the following strings: civic, madam, apple.

2. Write a method public static Stack reverse(Stack s) that reverses the order of elements on stack s using a Queue. Test your method using some example stacks.

2. Write a method public static boolean isBalanced(String expression), that checks if a given mathematical expression is balanced or not. The algorithm for evaluating parentheses is as follows: (a) Remove all non-parentheses from a mathematical expression. (b) Given an opening parenthesis, i.e., a ‘[‘, a ‘(‘ or a ‘{‘, push it onto the stack. (c) Given a closing parenthesis, pop an opening parenthesis from the stack: (i) if the closing parenthesis and the opening parenthesis match, it is a successful match (ii) if the parentheses do not match, the expression is not balanced (iii) if the stack is empty, the expression is not balanced (d) if, at the end of the program, the stack is empty, then the expression is balanced.

For example: [3 + (2 – 4) + {(a – b)}] is balanced, while [3 + 2( and { 7 + [ a – b} ] are not balanced.

The method takes as input a mathematical expression and outputs whether the input is balanced or not. Use stacks to find your answer. Test your method on ((3), [(3 + 4)] and {{( )( )}}.

In: Computer Science

Lili, a great magician, has a mission to enter a cave to get treasure inside. The...

Lili, a great magician, has a mission to enter a cave to get treasure inside. The cave only
has 1 path without branches. But the cave is not safe because there are some traps inside
that can reduce Lili’s life points. But in addition to traps, the cave also has potions that
can increase Lili’s life points. Before entering the cave, Lili casts magic that can reveal all
the traps and potions inside the cave. But before entering the cave, Lili must prepare her
life points first because in the cave because Lili cannot use her magic to add life points
or destroy the traps. What is the minimum life point that Lili must prepare so that her
life point is always positive during the trip inside the cave.
Note: If Lili’s point drops to 0 or negative before entering and during the trip inside the
cave, then Lili is declared dead.
Format Input
There are
T test cases. Each testcase contains an integer
N which represents the length
of the cave. On the next line there are
N numbers represents the value of trap and potion.
Traps are marked with numbers that are negative and potions are marked with numbers
that are positive
Format Output
Output
T line with format “Case
#
X: ”, where
X represents the testcase number and
Y represents the initial life points that Lili has to prepare.
Constraints • 1 ≤ T ≤ 100 • 1 ≤ N ≤ 5000 • −108 ≤ Ai ≤ 10
8
, which
A
i
is the value of each traps and potions.
Sample Input (standard input) 25
1 2 -3 4 -5 5
-1 -1 -1 -2 9
Sample Output (standard output)
Case #1: 2
Case #2: 6
Explanation
In case 1, the minimum life points that Lili must prepare is 2. With a simulation like the
following.
At position 1, Lili’s life point increased by 1 to 3.
At position 2, Lili’s life point increased by 2 to 5.
At position 3, Lili’s life point is reduced by 3 to 2.
At position 4, Lili’s life point increased to 4 to 6.
At position 5, Lili’s life point is reduced by 5 to 1.
In each position Lili’s life points are positive so the answer is valid. if the initial life
prepared by Lili is 1, then Lili will die in fifth position with a life point of 0.

Please answer it in C language , thx

In: Computer Science