Questions
Please note that this problem have to use sstream library in c++ (1) Prompt the user...

Please note that this problem have to use sstream library in c++

(1) Prompt the user for a title for data. Output the title. (1 pt)

Ex:

Enter a title for the data:
Number of Novels Authored
You entered: Number of Novels Authored


(2) Prompt the user for the headers of two columns of a table. Output the column headers. (1 pt)

Ex:

Enter the column 1 header:
Author name
You entered: Author name

Enter the column 2 header:
Number of novels
You entered: Number of novels


(3) Prompt the user for data points. Data points must be in this format: string, int. Store the information before the comma into a string variable and the information after the comma into an integer. The user will enter -1 when they have finished entering data points. Output the data points. Store the string components of the data points in a vector of strings. Store the integer components of the data points in a vector of integers. (4 pts)

Ex:

Enter a data point (-1 to stop input):
Jane Austen, 6
Data string: Jane Austen
Data integer: 6


(4) Perform error checking for the data point entries. If any of the following errors occurs, output the appropriate error message and prompt again for a valid data point.

  • If entry has no comma
    • Output: Error: No comma in string. (1 pt)
  • If entry has more than one comma
    • Output: Error: Too many commas in input. (1 pt)
  • If entry after the comma is not an integer
    • Output: Error: Comma not followed by an integer. (2 pts)


Ex:

Enter a data point (-1 to stop input):
Ernest Hemingway 9
Error: No comma in string.

Enter a data point (-1 to stop input):
Ernest, Hemingway, 9
Error: Too many commas in input.

Enter a data point (-1 to stop input):
Ernest Hemingway, nine
Error: Comma not followed by an integer.

Enter a data point (-1 to stop input):
Ernest Hemingway, 9
Data string: Ernest Hemingway
Data integer: 9


(5) Output the information in a formatted table. The title is right justified with a setw() value of 33. Column 1 has a setw() value of 20. Column 2 has a setw() value of 23. (3 pts)

Ex:

        Number of Novels Authored
Author name         |       Number of novels
--------------------------------------------
Jane Austen         |                      6
Charles Dickens     |                     20
Ernest Hemingway    |                      9
Jack Kerouac        |                     22
F. Scott Fitzgerald |                      8
Mary Shelley        |                      7
Charlotte Bronte    |                      5
Mark Twain          |                     11
Agatha Christie     |                     73
Ian Flemming        |                     14
J.K. Rowling        |                     14
Stephen King        |                     54
Oscar Wilde         |                      1


(6) Output the information as a formatted histogram. Each name is right justified with a setw() value of 20. (4 pts)

Ex:

         Jane Austen ******
     Charles Dickens ********************
    Ernest Hemingway *********
        Jack Kerouac **********************
 F. Scott Fitzgerald ********
        Mary Shelley *******
    Charlotte Bronte *****
          Mark Twain ***********
     Agatha Christie *************************************************************************
        Ian Flemming **************
        J.K. Rowling **************
        Stephen King ******************************************************
         Oscar Wilde *

In: Computer Science

Improve class OurLinkedList, so that its users can readily access a list's middle node. Readily here...

Improve class OurLinkedList, so that its users can readily access a list's middle node. Readily here means that when users instantiate an OurLinkedList object, they can access the node in the middle of the list without starting from the head, counting how many nodes to the end, then going back to the head, and skipping half as many nodes forward. In fact, there should be no counting for this improvement. Notice that lists with an even number of nodes, do not have a well defined middle node and it is up to you to determine which node near the middle will be considered the middle one.

Your improvement must be delivered only in the form of a new class that extends OurLinkedList. Name the extending class, after yourself, as following:

class YourfirstnameLinkedList extends OurLinkedList { ... }

replacing Yourfirstname above, with your actual first name (e.g., MyLinkedList).

SOURCE CODE FOR QUESTION

public class OurLinkedList {


class Node {
  
String value;
Node next;
  
Node(String v) {
value = v;
next = null;
} // constructor Node
} // class Node

/**
* Accessor for the field size.
* @return number of nodes in the list.
*/
public int getSize() {
return size;
} // method getSize

  
public boolean nodeExists(String v) {
// Initial assumption: no node found with string v
boolean stringFound = false;
// Start from the beginning.
Node currentNode = head;
if ( currentNode == null) {
// Empty list.
stringFound = false;
} else {
// List is not empty. Let's check if the last node contains
// string we are looking for. We do this here, because the
// last node is unreachable in a loop that terminates when
// .next == null.
stringFound = tail.value == v;
// Search through the rest of the linked list, hopping from
// node to node, following the .next pointer.
while (currentNode.next != null) {
if ( currentNode.value == v) {
stringFound = true;
}
currentNode = currentNode.next;
}
}
return stringFound;
} // method nodeExists


public void addNode(String v) {
if (!nodeExists(v)) {
// The list does not contain a node with the given string.
// Let's create one and call it newNode.
Node newNode = new Node(v);
// We are adding this newNode to the list, so let's increase the size.
size++;
// Now we need to determine where to add this new node.
if (head == null) {
// List is empty. Make this newNode the list's head.
head = new Node(v);
// Because the list is empty, make this node its tail as well.
tail = head;
} else {
// The list is not empty. Find its tail node and add the
// newNode after it.
tail.next = newNode;
// Make the newNode, the list's new tail.
tail = newNode;
}
}
}

public boolean remove(String v) {
boolean success = false;
if (nodeExists(v)) {
success = true;
}
return success;
}

class MyLinkedList extends OurLinked {...}


public static void main(String[] args) {
OurLinkedList demo = new OurLinkedList();
}

}

The question wants us to find the middle of the list immediately without traversing the linked list conventionally but any help is great. There is no need to print the list just to know where the middle of the list is.

In: Computer Science

I cannot figure out why my random name generator isn't producing the letter u or z....

I cannot figure out why my random name generator isn't producing the letter u or z. Can someone help me out? The language is java.

import java.util.Random;

public class BrandName {

   public static void main(String[] args) {
       Random random = new Random();
       System.out.println("Brand Name Generator - Michael Wikstrom\n");
       char odd[] = { 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y',
               'z' };
       char even[] = { 'a', 'e', 'i', 'o', 'u' };

       for (int i = 1; i <= 10; i++) {

           int length = random.nextInt(4) + 8;
           String name = " ";
           for (int j = 0; j < length; j++) {
               if (j == 0) {
                   int pos = random.nextInt(odd.length - 1);
                   name += Character.toUpperCase(odd[pos]);

               } else if (j % 2 == 1) {
                   int pos = random.nextInt(even.length - 1);
                   name += even[pos];
               } else {
                   int pos = random.nextInt(odd.length - 1);
                   name += odd[pos];
               }
           }

           System.out.println(i + ") " + name);

       }
   }

}

In: Computer Science

A Lecturer wishes to create a program that lists his students sorted by the number of...

A Lecturer wishes to create a program that lists his students sorted by the number of theory assignment marks they have completed. The listing should be greatest number of assignment first, sub-sorted by name in lexicographical order (A to Z). A class Student stores the name and marks of assignment completed for a student.                                                    [5 marks]

Note: Assume the variable name of collection is list.

      i.         Provide a definition of Student with an equals() method. The comparison is based on name of the student.                                                                                     [3 marks]

    ii.         Write java statement to declare a collection variable list of type Student             [2 marks]

   iii.         Implements interface Comparator such that fulfil a natural ordering that matches the given requirement. Define method compareTo() such that it compares based on greatest number of assignment first, sub-sorted by name in lexicographical order (A to Z)). [5 marks]

   iv.         Provide definition of find(String) method which returns the index if given name exists in collection.                                                                                                     [2 marks]

     v.         Provide a static method in application class to display all students by calling toString method. Assume the name of object of collection is list.                             [4 marks]

In: Computer Science

Identification of a Communication Theory: Uncertainty Reduction Theory Meta-theoretical Assumptions: How would the author of your...

Identification of a Communication Theory: Uncertainty Reduction Theory

Meta-theoretical Assumptions: How would the author of your theory define communication? Which of the 7 issues in defining communication discussed in class would be most important to the author of your theory? How do you know?

In: Operations Management

A restaurant association says the typical household in the U.S. spends a mean of $2600 per...

A restaurant association says the typical household in the U.S. spends a mean of $2600 per year on food away from home. An author of a national travel publication tests this claim and calculated a p-value of 0.8215. What conclusion can this author make at the 0.05 level of significance?

In: Statistics and Probability

How to display in SQL Server, for example, all the author First Names are FIVE LETTERS...

How to display in SQL Server, for example, all the author First Names are FIVE LETTERS LONG if I have the Author Table.

I used the WHERE LENGTH ua_fname=5  

This is not returning names with 5 letters. Can someone please suggest to me the correct one?

In: Computer Science

Consider the experimental results for the following randomized block design. Tasks A B C Individuals 1...

Consider the experimental results for the following randomized block design.

Tasks

A

B

C

Individuals

1

10

9

8

2

12

6

5

3

18

15

14

4

20

18

18

5

8

7

8

Suppose that you have an experiment wherein 5 individuals are each receiving training on 3 different tasks (A, B, and C). The values represent the number of minutes taken to complete the task. Suppose further that we are interested in determining whether there is a significant difference in the mean time taken to complete each of the tasks or not. State the name of the design of this experiment and all of the hypotheses that you would test. (Do NOT test.)

Type of test:

Hypotheses:

In: Statistics and Probability

1a) A survey was conducted to estimate the prevalence of a disease among a student population....

1a) A survey was conducted to estimate the prevalence of a disease among a student population. What type of epidemiological study is this?

Case-control

Cluster randomized trial

Longitudinal

Cross-sectional

Cohort

1b) Would this type of study be affected by selection bias? How?

1c) Would such bias affect prevalence estimate? How?

In: Biology

Describe Observational study designs: cohort study and case-control study. Choose an example for each study type...

Describe Observational study designs: cohort study and case-control study.

Choose an example for each study type and discuss the different statistical analysis used to interpret and analyze the results.

Suggest a case-control study that you prefer to conduct and explain the statistical tests that you would use in your study.

In: Statistics and Probability