Questions
Implement a superclass Person. Make two classes, Student and Instructor, that inherit from Person. A person...

Implement a superclass Person. Make two classes, Student and Instructor, that inherit from Person. A person has a name and a year of birth. A student has a major, and an instructor has a salary. Write the class declarations, the constructors, and the methods toString for all classes. Supply a test program that tests these classes and methods.

    1. Add a method
      Public static Measurable max(Measurable[ ] objects)
      to the Data class that returns the object with the largest measure.
    2. Implement a class Quiz that implements the Measurable interface (in Slide 6 of Chapter 10). A quiz has a score and a letter grade (such as B+). Supply a test program QuizTester that uses the Data class in a) to process an array of quizzes and display the average score and the quiz with the highest score (both letter grade and score).

    1. (Chapter 10, 30 points) Supply a class Person that implements the Comparable interface. Compare persons by their name. Ask the user to input ten names and generate ten Person objects. Using the compareTo method, determine the first and last person among them (in lexicographic order) and print them.

    In: Computer Science

    Visual Basic Question : Sum = 1 + 1/2 + 1/3 + 1/4 + ....... A...

    Visual Basic Question :

    Sum = 1 + 1/2 + 1/3 + 1/4 + .......

    A project which allows the user to enter a number in the Textbox1 and which indicates the number of terms on the Label
    

    e.g. I enter 10 (sum) in the Textbox1 and Label1 indicates 12367 (terms)

    I have tried a few days but it does not work... thanks for your help!

    dim i, t as integer

    for i = 1 to t-1

    textbox1 = textbox1 + 1/i

    next

    Label1 = t

    In: Computer Science

    Write a programme to read and print your phone number, your initials and your average. note:c++

    Write a programme to read and print your phone number, your initials and your average.
    note:c++

    In: Computer Science

    Question 1 i) A binary system uses 8-bits to represent an analog value ranging from 120...

    Question 1

    i) A binary system uses 8-bits to represent an analog value ranging from 120 ounces to 700 ounces, determine the resolution of the system and interprete your result.

    ii) Determine the number of bits that would be needed for the above resolution to improve to better than 0.01 ounces per increment. Interpret your results.

    iii) Use the binary coded decimal (BCD) representation of integers to represent each of the following integers.

    2194

    4576

    7865

    3947

    3782

    In: Computer Science

    Question 12: Please provide tilde (~) for the following expressions: A) 300N + (3N^5) + (4N^5)*logN...

    Question 12: Please provide tilde (~) for the following expressions:

    A) 300N + (3N^5) + (4N^5)*logN

    B) (N)^(1/2) + 6 ( NlogN / logN^2 )

    C) N^100/ 2^N

    D) 1 + 1/N

    In: Computer Science

    How to compile this code on Visual Studio? Because it keeps getting me an error when...

    How to compile this code on Visual Studio?

    Because it keeps getting me an error when i compile it.

    #include<iostream.h>
    #include<cio.h>
    class Array
    {
    public:

    Array(int=0)//initalise the array with 0 value

    Array(const Array &);
    ~Array();
    private:
    int size;
    int *arr;
    bool setvalue(int index,int value);
    bool getvalue(int index,int &value);

    Array & increment();
    int getsize();
    void print();
    Array &Add(const Array arr);
    bool Equal(const Array *arr)const;
    Array &removeAt(int index);
    Array &insertAt(int index,int value);

    }; //End of Array class


    void Array::setvalue(int index,int value) //set value for array
    {
    i=index;
    x=value;
    }
    void Array::getvalue(int index,int value) //get array element
    {
    i=index;
    x=&value;
    }

    void Array::getsize() //return the size of the array
    {
    cout<<arr.size();

    }

    void Array::print() //display array element
      
    {
    cout << x<endl;   
    }
    void Array::Add(int arr[])
    {

    int i;
    for (i = 0; i < 5; i++)
    arr[i]++; // this alters values in array in main()

    }


    void main()

    {

    Array A;
    int arr[5];
      

    cout << "Please Enter " << A.getSize() << " elements for A1 :";

    int x;

    for (int i = 0; i < A.getSize(); i++)

    {

    cin >> x;

    A.setValue(i, x);

    }

    Array B(5);

    cout << "Please Enter " << B.getSize() << " elements for B : ";

    for (int i = 0; i < B.getSize(); i++)

    {

    cin >> x;

    B.setValue(i, x);

    }

    cout << "Testing copy constrcutor : Array X(A); D = ";

    Array X(A);

    X.print();

    cout << endl;

    cout << "I am printing A using getValue assuming that I don't know the size,\nA = ";

    int i = 0;

    while (A.getValue(i, x))

    {

    cout << x << " ";

    i++;

    }

    cout << "\nArray C = A.increment(), printing (using A.print()) A and C after the function call\nA = ";

    Array C = A.increment();

    A.print();

    cout << "\nC = ";

    C.print();

    cout << "\nA.Equal(C) = " << A.Equal(&C) << endl;

    cout << "A.Equal(B) = " << A.Equal(&B) << endl;

    cout << "Array D = A.Add(B) = ";

    Array D = A.Add(B);

    D.print();

    cout << "\nA is ";

    A.print();

    cout << "\nB is ";

    B.print();

    cout << endl;

    cout << "Inserting 99 at index 99999 in A, the result is :\n";

    A.insertAt(99999, 99);

    A.print();

    cout << endl;

    cout << "Inserting -99 at index -99999 in A, the result is :\n";

    A.insertAt(-99999, -99);

    A.print();

    cout << endl;

    cout << "Inserting 7 at index 3 in A, the result is :\n";

    A.insertAt(3, 7);

    A.print();

    cout << endl;

    cout << "Deleting the element at index 2 from A, the result is :\n";

    A.removeAt(2);

    A.print();

    cout << endl;
    getch();
    }

    In: Computer Science

    Create a program that reports whether each word in a set of words appears in a...

    Create a program that reports whether each word in a set of words appears in a paragraph. Here are the requirements: a. Ask the user to enter a set of words, one at a time. Use an appropriate prompt to keep asking for words until a blank line is entered. The set of words should be in a dictionary, where the word is the key, and “yes” or “no” is the value. The value represents whether the word appears in the paragraph. As the words are entered, the value should initially be “no”. b. Ask the user to enter a paragraph. Use an appropriate prompt to keep asking for lines/sentences of the paragraph. The lines/sentences should be in a list (of strings). When the user enters a blank line, the paragraph is complete. c. Once the paragraph is entered, check to see if each word in the dictionary is in the paragraph. If it is, then set the value of that key (word) to “yes”. It is sufficient to determine if the word is in the paragraph. You do not need to find all instances, nor count the number of instances. d. Present the results by writing the results of the dictionary using a loop. (Do not simply print the dictionary as a whole.) This should appear as two columns of data, with the key in the first column, and the corresponding value of “yes” or “no” in the second column.

    In: Computer Science

    In two paragraph, explain the hierarchical structure of a system that you have worked on and...

    In two paragraph, explain the hierarchical structure of a system that you have worked on and how emergence affects the levels in the systems hierarchy. Provide details and apply what you learned here to discuss what (if any) changes you would have done, if you have to do it all over again.


    must be about a computer or software system

    In: Computer Science

    Describe how DDoS attacks may be mounted against TCP and UDP services. In what way will...

    Describe how DDoS attacks may be mounted against TCP and UDP services. In what way will being connection oriented be different for TCP and UDP?

    In: Computer Science

    Using the below given ASCII table (lowercase letters) convert the sentence “welcome to cci college” into...

    Using the below given ASCII table (lowercase letters) convert the sentence “welcome to cci college” into binary values.

    a - 97

    b - 98

    c - 99

    d - 100

    e - 101

    f - 102

    g - 103

    h - 104

    i - 105

    j - 106

    k - 107

    l - 108

    m - 109

    n - 110

    o - 111

    p - 112

    q - 113

    r -114

    s -115

    t - 116

    u - 117

    v - 118

    w - 119

    x - 120

    y - 121

    z - 122

    Space - 32

    In: Computer Science

    Write LMC assembly code that prints the minimum of two numbers. HINT: use and extend the...

    Write LMC assembly code that prints the minimum of two numbers.

    HINT: use and extend the table below for your solution.

    Mailbox

    Mnemonic

    Code

    Instruction description

    In: Computer Science

    Add The following methods to the LinkedQueue class and create a test driver for each to...

    Add The following methods to the LinkedQueue class and create a test driver for each to show they work correctly. In order to practice your linked list coding skills, code each of these methods by accessing the internal variables of the LinkedQueue, not by calling the previously defined public methods of the class. a. String toString () creates and returns a string that correctly represents the current queue. Such a method could prove useful for testing and debugging the class and for testing and debugging applications tha

    t use the class. Assue each queued element already provides its own reasonable toString method. b. void remove (int count) removes the front count elements from the queue; throws QueueUnderflowException if less than count elements are in the queue. c. boolean swapStart () returns false if less than two elements are in the queue, otherwise reverse the order of the front two elements in the queue and returns true. d. boolean swapEnds() returns false if there are less than two elements in the queue, otherwise swaps the first and last elements of the queue and returns true.

    LinkedQueue.java:

    package ch04.queues;

    import support.LLNode;

    public class LinkedQueue<T> implements QueueInterface<T> {

        protected LLNode<T> front;

        protected LLNode<T> rear;

        protected int numElements = 0;

        public LinkedQueue(){

            front = null; rear = null;

        }

        public void enqueue(T element){

            LLNode<T> newNode = new LLNode<T>(element);

            if (rear == null)

                front = newNode;

            else

                rear.setLink(newNode);

            rear = newNode;

            numElements++;

        }

        public T dequeue(){

            if (isEmpty())

                throw new QueueUnderflowException("Dequeue attempted on empty queue.");

            else{

                T element;

                element = front.getInfo();

                front = front.getLink();

                if (front == null)

                    rear = null;

                numElements--;

                return element;

            }

        }

    }

    LLNode.java:

    //----------------------------------------------------------------------------

    // LLNode.java by Dale/Joyce/Weems Chapter 2

    //

    // Implements <T> nodes for a Linked List.

    //----------------------------------------------------------------------------

    package support;

    public class LLNode<T>{

        private LLNode<T> link;

        private T info;

        

        public LLNode(T info)

        {

            this.info = info;

            link = null;

        }

        

        public void setInfo(T info){

            // Sets info of this LLNode.

            this.info = info;

        }

        

        public T getInfo()

        // Returns info of this LLONode.

        {

            return info;

        }

        

        public void setLink(LLNode<T> link)

        // Sets link of this LLNode.

        {

            this.link = link;

        }

        public LLNode<T> getLink()

        // Returns link of this LLNode.

        {

            return link;

        }

    }

    QueueInterface.java

    package ch04.queues;

    public interface QueueInterface<T> {

        

        void enqueue(T element) throws QueueOverflowException1;

        T dequeue() throws QueueUnderflowException;

        boolean isFull();

        boolean isEmpty();

        int size();

    }

    In: Computer Science

    use c++ Parking charge application: A parking garage charges a $20.00 minimum fee to park for...

    use c++

    Parking charge application: A parking garage charges a $20.00 minimum fee to park for up to 3 hours. The garage charges an additional $5.00 per hour for hour or part thereof in excess of 3 hours. The maximum charge for any given 24-hour period is $50.00. Assume that no car parks for longer than 24 hours at a time. Write a program that calculates and prints the parking charge for each of 3 customers who parked their cars in this garage yesterday. You should enter the hours parked for each customer. Your program should save the result in a array of Customer. The class customer is the following:

    class customer{ string plate; float hour; float fee; }

    Your program should use the function calculateCharges to determine the fee for each customer. You should print the result for the 3 customers in the following format:

    Plate Hours Charge

    132AAC 1.5 20.00

    236URT 4.0 25.00

    390ROP 24.0 50.00

    TOTAL 29.5 95.00

    In doing this question make sure to keep the array of customer as global variable.

    In: Computer Science

    You must implement the delete method. Below are the requirements: • The delete method takes a...

    You must implement the delete method. Below are the requirements:

    • The delete method takes a Price as an argument and removes the Price from the queue if it is present. (If the Price was not present, the method does nothing).

    • The method returns true if the Price was deleted and false otherwise.

    • The method must run in logarithmic time. This is a key requirement. Solutions that are linear or worse will not receive credit. (You may assume that the running time for TreeMap’s operations are similar to the LLRB class in the book. You can also read the API for TreeMap to see what the running times for the various methods are.)

    • You may not modify the function headers of any of the functions already present.

    • The only field you may add to the PriceQueue class is a single TreeMap. (See Java’s API for the TreeMap class. It is basically the same as the book’s RedBlackBST class)

    • You may not change or remove the package declaration at the top of the files.

    • The rest of the queue should continue to behave as expected. In particular, the remaining Prices should still come out of the queue in FIFO order.

    • The enqueue and dequeue methods should also run in logarithmic time while the size, peek, and isEmpty methods continue to run in constant time. Note, the enqueue method given to you runs in linear time because it scans the list to see if the price being added is already in the queue. You will need to replace this with a different way of checking that doesn’t take linear time. (Hint: Use the map!) • You will need to make changes to the Price class as well, but you can only add new functionality. You may not make any changes to the functions that are already there and they must continue to behave as before.

    //// PRICE JAVA /////

    public class Price {

    private int dollars;

    private int cents;

    public Price(int dollars, int cents) {

    if (dollars < 0 || cents < 0 || cents > 99)

    throw new IllegalArgumentException();

    this.dollars = dollars;

    this.cents = cents;

    }

    public String toString() {

    String answer = "$" + dollars + ".";

    if (cents < 10)

    answer = answer + "0" + cents;

    else

    answer = answer + cents;

    return answer;

    }

    @Override

    public boolean equals(Object obj) {

    if (this == obj)

    return true;

    if (obj == null)

    return false;

    if (getClass() != obj.getClass())

    return false;

    Price other = (Price) obj;

    if (cents != other.cents)

    return false;

    if (dollars != other.dollars)

    return false;

    return true;

    }

    }

    /////// PRICE QUEUE //////

    import java.util.Iterator;
    import java.util.NoSuchElementException;

    public class PriceQueue implements Iterable<Price> {
    private Node first; // beginning of queue
    private Node last; // end of queue
    private int n; // number of elements on queue
    // TODO - Add a TreeMap that maps prices to the node before that price in the queue
    // and maps the first price (nothing before it) to null
    //
    // NOTE: You will need to modify preexisting methods to maintain the invariant on the TreeMap

    // helper linked list class
    private static class Node {
    private Price price;
    private Node next;
    }

    /**
    * Initializes an empty queue.
    */
    public PriceQueue() {
    first = null;
    last = null;
    n = 0;
    }

    /**
    * Returns true if this queue is empty.
    *
    * @return {@code true} if this queue is empty; {@code false} otherwise
    */
    public boolean isEmpty() {
    return first == null;
    }

    /**
    * Returns the number of Prices in this queue.
    *
    * @return the number of Prices in this queue
    */
    public int size() {
    return n;
    }

    /**
    * Returns the Price least recently added to this queue.
    *
    * @return the Price least recently added to this queue
    * @throws NoSuchElementException if this queue is empty
    */
    public Price peek() {
    if (isEmpty()) throw new NoSuchElementException("Queue underflow");
    return first.price;
    }

    /**
    * Adds the Price to this queue if it is not already present,
    * otherwise it throws an IllegalArugmentException.
    *
    * @param price the Price to add
    *
    * @throws IllegalArgumentException if price is already in the queue.
    */
    public void enqueue(Price price) {
       for(Price p : this)
           if (p.equals(price))
               throw new IllegalArgumentException();
    Node oldlast = last;
    last = new Node();
    last.price = price;
    last.next = null;
    if (isEmpty()) first = last;
    else oldlast.next = last;
    n++;
    }

    /**
    * Removes and returns the Price on this queue that was least recently added.
    *
    * @return the Price on this queue that was least recently added
    * @throws NoSuchElementException if this queue is empty
    */
    public Price dequeue() {
    if (isEmpty()) throw new NoSuchElementException("Queue underflow");
    Price price = first.price;
    first = first.next;
    n--;
    if (isEmpty()) last = null; // to avoid loitering
    return price;
    }
      
      
    /**
    * Deletes a Price from the queue if it was present.
    * @param price the Price to be deleted.
    * @return {@code true} if the Price was deleted and {@code false} otherwise
    */
    public boolean delete(Price price) {
       // TODO implelment me!!!
       // Make sure the running time is no worse than logrithmic!!!
       // You will want to use Java's TreeMap class to map Prices to the node
       // that precedes the Price in the queue
       throw new RuntimeException("Not Implemented!!!");
    }

    /**
    * Returns a string representation of this queue.
    *
    * @return the sequence of Prices in FIFO order, separated by spaces
    */
    public String toString() {
    StringBuilder s = new StringBuilder();
    for (Price price : this) {
    s.append(price);
    s.append(' ');
    }
    return s.toString();
    }

    /**
    * Returns an iterator that iterates over the Prices in this queue in FIFO order.
    *
    * @return an iterator that iterates over the Prices in this queue in FIFO order
    */
    public Iterator<Price> iterator() {
    return new PriceListIterator(first);
    }

    // an iterator, doesn't implement remove() since it's optional
    private class PriceListIterator implements Iterator<Price> {
    private Node current;

    public PriceListIterator(Node first) {
    current = first;
    }

    public boolean hasNext() { return current != null; }
    public void remove() { throw new UnsupportedOperationException(); }

    public Price next() {
    if (!hasNext()) throw new NoSuchElementException();
    Price price = current.price;
    current = current.next;
    return price;
    }
    }
    }

    In: Computer Science

    Define a class Product to hold the name and price of items in a grocery store....

    Define a class Product to hold the name and price of items in a grocery store. Encapsulate the fields and provide getters and setters. Create an application for a grocery store to calculate the total bill for each customer. Such program will read a list of products purchased and the quantity of each item. Each line in the bill consists of: ProductName ProductPrice Quantity/Weight

    The list of items will be terminated by the “end” keyword. The data will look like this: Juice 10 7 Apples 3 3.5 Cereal 5 3 Gum 1 15 Pears 3.5 5 ends The program should read the data from the console, calculate the total price of the items purchased and print it out. For each line create an object of class Product and initialize its fields in the constructor. Then calculate the price for given quantity using the getter of the object.

    In: Computer Science