Questions
Comments : For each function in your program, you must include a comment block that includes...

Comments :
For each function in your program, you must include a comment block that includes a name of the function, the input parameters of the function, and the return type of the function. Use short phrase descriptions to describe each.

Guard Conditions and Exception Handling:
This time, your program must guard against common errors. An empty vector cannot be used for a variance or standard deviation. A file must be opened correctly. A file must be written to correctly.


Part 1: The Main and the Menu and the Name on the Output
As with the previous two programs, this project will start with a main.

In addition, it should call a version of a print-your-name function and a menu.


The Menu will contain the following items.


1. Load From a File

2. Calculate the Statistics

3. Write to a File

4. Perform the count

5. Display the Bargraph

6. Quit

Part 2: Load from a File
The first step of this assignment is to read 100,000 numbers from a comma-separated value file.

First, the user will be prompted for the name of the file.

Second, the file must be opened correctly.

Third, all the values must be read into a vector and returned.

Fourth, the file must be closed.

Fifth, the vector must be returned to the Menu function.

Part 3: Calculate the Statistics
Use functions to calculate the total, average, variance, and standard deviation of the numbers in the data vector. These values should be returned and stored in local variables in the menu function.



Part 4: Writing to a File
First, prompt the user for a filename. Second, open a file for output. Then, write the information to the file such that it looks like the following:


Your Name
---------------
Total : 0.00
Average : 0.00
Variance: 0.00
StDev : 0.00

Replace Your Name with your name

Replace each 0.00 with the correct value as a double with two-decimal places.

Finally, close the file cleanly.

Part 4: Perform the count.

This next part is a new piece of the programming. Students will have to create a class called Counter, and initialized to 0 in the local scope.

Class Counter will have an integer count for the values 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, and 12.

The class Counter would have 11 integers, one for each value.

A shortcut would be to have a vector of 13 integers, and ignore the indexes of 0 and 1.


· The class should have a constructor that will set all the counters to 0.
· The class should have a function Increment(int index), that will increase a counter by one based on the input parameter of 2 through 12.
· The class should have a function ShowCount(), which will print out a list of all the counters to the screen. Such as:


Sample output; This is just an example; the real counts will be different.

2| 1000
3| 2000
4| 3000
5| 2000
6| 3000
7| 4000
8| 2000
9| 1000
10| 5000
11| 4000
12| 20000

· Finally, the class should have a function Normalize(int index), with a parameter that is the index. For that index, divide the total by 1000, and truncate to an integer. The type-casting (int) works well. Return the integer.


From the menu, use a loop to go through the vector, operate the Increment function, and then show the count.


Part 5: Showing a text-only Bargraph

The final function is the bargraph function. Using a pair of nested loops, show a bargraph of the numbers.


Sample code:

int rowmax=0;
for (i=2;i<=12;i++)
{
cout<<i;
cout<<”|”;
rowmax=myCounter.Normalize(i);
for (j=0;j<rowmax;j++)
{
cout<<”X”;
}
cout<<endl;
}


And the output would look something like the figure below. Be aware that the bar graphs will be different.


2|X
3|XX
4|XXX
5|XX
6|XXX
7|XXXX
8|XX
9|X
10|XXXXX
11|XXXX
12|XXXXXXXXXXXXXXXXXXXXX

the above program is in c++ language and the menu has to be created with a switch function.

theres a file guven of 100,000 numbers ranging from 1 to 12

In: Computer Science

C++ PLEASE This will be a multi-part assignment. Later homework will expand upon what is developed...

C++ PLEASE

This will be a multi-part assignment. Later homework will expand upon what is developed in this assignment.

1. Create a class called MyComplex to represent complex numbers. Each part (Real and Imaginary parts) should be stored as a double. Data members should be private and you need to supply appropaiate accessor and mutator methods.

2. Supply a default constructor (both parts zero), a constructor that allows the real part to be set and a third constructor that allows both parts to be set.

3. Supply an insertion operator that will allow the value of a complex number to be printed. The output should look like: 2+3i, 1-4i, -2+0i, 0+5i for example.

4. Supply a complete program that exercises your class. (be sure you also exercise the accessor and mutator functions). You must supply a listing of your program and sample output.

In: Computer Science

3. Add mutex locks to tprog2.c to achieve synchronization, and screenshot the output tprog2.c #include <stdio.h>...

3. Add mutex locks to tprog2.c to achieve synchronization, and screenshot the output 

tprog2.c 

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
void* print_i(void *ptr)
{
  printf("1: I am \n");
  sleep(1);
  printf("in i\n");

}

void* print_j(void *ptr)
{
  printf("2: I am \n");
  sleep(1);
  printf("in j\n");

}

int main() {

  pthread_t t1,t2;

int rc1 = pthread_create(&t1, NULL, print_i, NULL); int rc2 = pthread_create(&t2, NULL, print_j, NULL);

exit(0);

}

In: Computer Science

In Java: Initiate empty queue of strings and recreate .isempty, .size, .dequeue, .enqueue methods. //You may...

In Java: Initiate empty queue of strings and recreate .isempty, .size, .dequeue, .enqueue methods.

//You may not use the original methods of the stack api to answer. You may not add any more fields to the class.

import java.util.NoSuchElementException;

import edu.princeton.cs.algs4.Stack;


public class StringQueue {
   //You may NOT add any more fields to this class.
   private Stack stack1;
   private Stack stack2;

   /**
   * Initialize an empty queue.
   */
   public StringQueue() {

//TODO
   }

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

   /**
   * Returns the number of items in this queue.
   *
   * @return the number of items in this queue
   */
   public int size() {
       // TODO
   }


   /**
   * Adds the item to this queue.
   *
   * @param item the item to add
   */
   public void enqueue(String item) {
       // TODO
   }

   /**
   * Removes and returns the item on this queue that was least recently added.
   *
   * @return the item on this queue that was least recently added
   * @throws NoSuchElementException if the queue is empty
   */
   public String dequeue() throws NoSuchElementException {
       // TODO
   }
}

Hints:
You will need to store enqueued items on one of the stacks. However, when it comes time to dequeue, those items will be in the wrong order, so use the second stack to reverse the order. Note that once the items are in the second stack, they will come out of the second stack in the correct order and you can still use the first stack to store new items that are enqueued. You should not keep moving the strings back and forth between the two stacks as this will make your solution extremely inefficient. Each string should be inserted into stack1 and most once and into stack2 at most once.
I suggest you start with the very simple sequence: enqueue(“one”), enqueuer(“two”), dequeue(), dequeue(). Of course, the String “one” should come out first followed by the String “two”. Once you have that working, start testing your code with more complex sequences and fixing any use cases you missed in your original attempt at a solution. For example, make sure to at least try the seuquence enqueue(“one”), enqueuer(“two”), dequeue(), enqueue(“three”), dequeue(), dequeue().

In: Computer Science

2.explain the need and rational of small scale industry list out the different steps to start...

2.explain the need and rational of small scale industry list out the different steps to start a ssi.(50marks)

Need own answer and no internet answers r else i il downvote nd report to chegg.Even a single is wrong i il downvote.its 50marks question so no short answer minimum 10page answer required and own answer r else i il downvote.

Note:Minimum 10page answer and no plagarism r else i il downvote and report to chegg.Minimum 10 to 15page answer required r else dnt attempt.strictly no internet answer n no plagarism.

its 50marks question so i il stricly review nd report

In: Computer Science

Use case Names: Record a Ticket Scenario: Officer Issues a Ticket Triggering Event: Traffic Ticket Description:...

Use case Names: Record a Ticket

Scenario: Officer Issues a Ticket

Triggering Event: Traffic Ticket

Description: The Officer provides the Clerk with the ticket. And then the ticket information is verified by the clerk. First he/she enters the Officers badge number and next enters the drivers license number to verify their information.

Action: Clerk

Stakeholders: Manager, Officer

Precondition: The officer and driver must exist.

Postcondition: The ticket must exit and be associated with the Officer, the driver, and the Court.

Exception Conditions: Officer not found, Driver not found.

Flow of Event:

Action

System

1. Officer enters offices badge number.

System reads officer information and displays name.

2. Officer enters drivers license number.

System reads the drivers information and displays the drivers name and address.

3. Clerk enters ticket information.

System displays ticker and drivers information.

Task

  1. Develop a DFD diagram 0 for the use case based on the narratives. Diagram 0 should include major processes in the use case. Group use case steps into a few processes (for example, three or four). Do not model each step. No child diagrams needed.   
  2. Develop an Activity diagram for the use case based on the narrative.

In: Computer Science

Question 1 (20 marks) Refer to the operations below: Add (10 + 5) Add (4+8) Add...

Question 1

Refer to the operations below:

Add (10 + 5)

Add (4+8)

Add (7*2)

Add (90 – 3)

Print list

Print peek

Remove an item from the list

Print list

1.1 Implement the operations above into a Queue structure called q1.

(10)

1.2 Implement the operations above into a Stack structure called s1.

(10

Guidelines: Please take note!

(a) Name your program Question1_1 for the queue structure and Question1_2 for the stack structure

(b) The Java Programmer is required to include screenshots from a JGrasp IDE which displays their commented code and the output and also indicates their laptop date and time of code execution, the screenshot of the code needs to be error-free and must not produce any logic errors!

In: Computer Science

function varargout = untitled(varargin) gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn',...

function varargout = untitled(varargin)

gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled_OpeningFcn, ...
'gui_OutputFcn', @untitled_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


function untitled_OpeningFcn(hObject, eventdata, handles, varargin)

handles.output = hObject;


guidata(hObject, handles);


function varargout = untitled_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;


function pushbutton1_Callback(hObject, eventdata, handles)

handles.img2=uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
'*.*','All Files' },'G:\dipproject')

img=handles.img2;
  
axes(handles.axes1)   
  
imshow(img);

guidata(hObject, handles);


function pushbutton3_Callback(hObject, eventdata, handles)

img=handles.img2;
img=imread(img)
bw=im2bw(img,0.7);
label=bwlabel(bw);
stats=regionprops(label,'Solidity','Area');
density=[stats.Solidity];
area=[stats.Area];
high_dense_area=density>0.5;
max_area=max(area(high_dense_area));
tumor_label=find(area==max_area);
tumor=ismember(label,tumor_label);
se=strel('square',5);
tumor=imdilate(tumor,se);
axes(handles.axes2)
  
imshow(tumor,[]);

guidata(hObject, handles);


function pushbutton4_Callback(hObject, eventdata, handles)

img=handles.img2;
img=imread(img)   

contents=get(hObject,'value')
bw=im2bw(img,0.7);
label=bwlabel(bw);
stats=regionprops(label,'Solidity','Area');
density=[stats.Solidity];
area=[stats.Area];
high_dense_area=density>0.5;
max_area=max(area(high_dense_area));
tumor_label=find(area==max_area);
tumor=ismember(label,tumor_label);
se=strel('square',5);
tumor=imdilate(tumor,se);
[B,L]=bwboundaries(tumor,'noholes');


axes(handles.axes3)
imshow(img,[]);
hold on
for i=1:length(B)
plot(B{i}(:,2),B{i}(:,1), 'y' ,'linewidth',1.45);
end
guidata(hObject, handles);

function pushbutton5_Callback(hObject, eventdata, handles)

clc
clear all;
close all;

Please explain this code step by step matlab program

In: Computer Science

Consider the following classes: public class Clock extends Bear { public void method3() { System.out.println("Clock 3");...

Consider the following classes:

public class Clock extends Bear {
  public void method3()      {
    System.out.println("Clock 3");
  }
}

public class Lamp extends Can    {
  public void method1()      {
    System.out.println("Lamp 1");
  }

  public void method3()      {
    System.out.println("Lamp 3");
  }
}

public class Bear extends Can    {
  public void method1()      {
   System.out.println("Bear 1");
  }
  
  public void method3()      {
    System.out.println("Bear 3");
    super.method3();
  }
}

public class Can {
  public void method2()      {
    System.out.println("Can 2");
    method3();
  }

  public void method3()      {
    System.out.println("Can 3");
  }
}

---and that the following variables are defined:---

Object var1 = new Bear();
Can var2 = new Can();
Can var3 = new Lamp();
Bear var4 = new Clock();
Object var5 = new Can();
Can var6 = new Clock();

For each statement below , match the output produced in the right-hand column by the statement in the left-hand column. If the statement produces more than one line of output, the line breaks are indicated with slashes as in "a/b/c" to indicate three lines of output with "a" followed by "b" followed by "c". If the statement causes an error, choose in the right-hand column with either the phrase "compiler error" or "runtime error" to indicate when the error would be detected.

Note: Multiple statements can have the same output (ex: Compiler Error or Runtime Error)

var1.method2();

var2.method2();

var3.method2();

var4.method2();

var5.method2();

var1.method3();

var2.method3();

var3.method3();

var6.method3();

((Lamp)var6).method1();

((Can)var1).method1();

((Can)var1).method2();

((Bear)var1).method3();

((Clock)var1).method1();

---The choices for all methods are:---

Clock 3

Can 2/Can 3

Runtime Error

Compiler Error

Can 2/Bear 2/Can 3

Can 2/Clocl 3

Can 3

Bear3/Can 3

In: Computer Science

Using PHP, design a function that given a Roman numeral (Wikipedia link.), in input, is able...

Using PHP, design a function that given a Roman numeral (Wikipedia link.), in input, is able to compute the modern Hindu–Arabic numeral (wikipedia link), system representation (aka, 0123456789).

For example:

Input Output
VI 6
IV 4
MCMXC 1990
IX 9
  • Be sure to add all the necessary checks and at least one testing function.
  • Try to split the logic in more small functions.

In: Computer Science

Input Format 4 1 2 3 4 Constraints there will be no more than 50 input...

Input Format

4 1 2 3 4

Constraints

there will be no more than 50 input numbers.

Output Format

Odd: 2 Even: 2 Divisible by 7: 0 Average: 250

Sample Input 0

4
1 2 3 4

Sample Output 0

Odd: 2
Even: 2
Divisible by 7: 0
Average: 250

import java.io.*;

import java.math.*;

import java.security.*;

import java.text.*;

import java.util.*;

import java.util.concurrent.*;

import java.util.regex.*;



public class Solution {

    public static void main(String[] args) throws IOException {

        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(bufferedReader.readLine().trim());

        String[] arrTemp = bufferedReader.readLine().replaceAll("\\s+$", "").split(" ");

        List<Integer> arr = new ArrayList<>();

        for (int i = 0; i < n; i++) {

            int arrItem = Integer.parseInt(arrTemp[i]);

            arr.add(arrItem);

        }

        // You now have an array of integers called arr. You should process the array to achieve the results.

        // note that you can refer to items in arr using standard Java array notation

        // arr[0] will give you the item at location 0 in this array

        // Write your code here

        bufferedReader.close();

    }

}

In: Computer Science

JAVA Programming (Convert decimals to fractions) Write a program that prompts the user to enter a...

JAVA Programming

(Convert decimals to fractions)

Write a program that prompts the user to enter a decimal number and displays the number in a fraction.

Hint: read the decimal number as a string, extract the integer part and fractional part from the string, and use the Rational class in LiveExample 13.13 to obtain a rational number for the decimal number. Use the template at

https://liveexample.pearsoncmg.com/test/Exercise13_19.txt

for your code.

Sample Run 1

Enter a decimal number: 3.25
The fraction number is 13/4

Sample Run 2

Enter a decimal number: -0.45452
The fraction number is -11363/25000

The output must be similar to the Sample Runs ( Enter a decimal number: etc.)


Class Name MUST be Exercise13_19

If you get a logical or runtime error, please refer https://liveexample.pearsoncmg.com/faq.html.

RATIONAL CLASS:

/* You have to use the following template to submit to Revel.
   Note: To test the code using the CheckExerciseTool, you will submit entire code.
   To submit your code to Revel, you must only submit the code enclosed between
     // BEGIN REVEL SUBMISSION

     // END REVEL SUBMISSION
*/
import java.util.Scanner;

// BEGIN REVEL SUBMISSION
public class Exercise13_19 {
  public static void main(String[] args) {
    // Write your code
  }
}
// END REVEL SUBMISSION

// Copy from the book
class Rational extends Number implements Comparable<Rational> {
  // Data fields for numerator and denominator
  private long numerator = 0;
  private long denominator = 1;

  /** Construct a rational with default properties */
  public Rational() {
    this(0, 1);
  }

  /** Construct a rational with specified numerator and denominator */
  public Rational(long numerator, long denominator) {
    long gcd = gcd(numerator, denominator);
    this.numerator = (denominator > 0 ? 1 : -1) * numerator / gcd;
    this.denominator = Math.abs(denominator) / gcd;
  }

  /** Find GCD of two numbers */
  private static long gcd(long n, long d) {
    long n1 = Math.abs(n);
    long n2 = Math.abs(d);
    int gcd = 1;
    
    for (int k = 1; k <= n1 && k <= n2; k++) {
      if (n1 % k == 0 && n2 % k == 0) 
        gcd = k;
    }

    return gcd;
  }

  /** Return numerator */
  public long getNumerator() {
    return numerator;
  }

  /** Return denominator */
  public long getDenominator() {
    return denominator;
  }

  /** Add a rational number to this rational */
  public Rational add(Rational secondRational) {
    long n = numerator * secondRational.getDenominator() +
      denominator * secondRational.getNumerator();
    long d = denominator * secondRational.getDenominator();
    return new Rational(n, d);
  }

  /** Subtract a rational number from this rational */
  public Rational subtract(Rational secondRational) {
    long n = numerator * secondRational.getDenominator()
      - denominator * secondRational.getNumerator();
    long d = denominator * secondRational.getDenominator();
    return new Rational(n, d);
  }

  /** Multiply a rational number to this rational */
  public Rational multiply(Rational secondRational) {
    long n = numerator * secondRational.getNumerator();
    long d = denominator * secondRational.getDenominator();
    return new Rational(n, d);
  }

  /** Divide a rational number from this rational */
  public Rational divide(Rational secondRational) {
    long n = numerator * secondRational.getDenominator();
    long d = denominator * secondRational.numerator;
    return new Rational(n, d);
  }

  @Override  
  public String toString() {
    if (denominator == 1)
      return numerator + "";
    else
      return numerator + "/" + denominator;
  }

  @Override // Override the equals method in the Object class 
  public boolean equals(Object other) {
    if ((this.subtract((Rational)(other))).getNumerator() == 0)
      return true;
    else
      return false;
  }

  @Override // Implement the abstract intValue method in Number 
  public int intValue() {
    return (int)doubleValue();
  }

  @Override // Implement the abstract floatValue method in Number 
  public float floatValue() {
    return (float)doubleValue();
  }

  @Override // Implement the doubleValue method in Number 
  public double doubleValue() {
    return numerator * 1.0 / denominator;
  }

  @Override // Implement the abstract longValue method in Number
  public long longValue() {
    return (long)doubleValue();
  }

  @Override // Implement the compareTo method in Comparable
  public int compareTo(Rational o) {
    if (this.subtract(o).getNumerator() > 0)
      return 1;
    else if (this.subtract(o).getNumerator() < 0)
      return -1;
    else
      return 0;
  }
}

In: Computer Science

Create an example schema representing Edgar Rice Burroughs published works starting with him as an author...

Create an example schema representing Edgar Rice Burroughs published works starting with him as an author and representing most of the metadata present in the following site/list of books.

http://www.gutenberg.org/ebooks/author/48 (Links to an external site.)

You need to include 5 books in your example schemas.

Create a JSON schema representing 5 of an author (Edgar Rice Burroughs) works.

In: Computer Science

JAVA Start with the SelectionSort class in the zip file attached to this item. Keep the...

JAVA

Start with the SelectionSort class in the zip file attached to this item. Keep the name SelectionSort, and add a main method to it.

  • Modify the selectionSort method to have two counters, one for the number of comparisons, and one for the number of data swaps. Each time two data elements are compared (regardless of whether the items are in the correct order—we're interested in that a comparison is being done at all), increment the comparison counter. Each time two data items are actually swapped, increment the data swap counter.
  • At the end of the selectionSort method, print the size of the sorted array, and the counters. (Be sure to identify which counter is which in your print message
  • In your main method,
    • Declare a final int, NUM_ELEMENTS. Initially set NUM_ELEMENTS to 10 to debug your program.
    • Declare and create three double arrays of NUM_ELEMENTS length, lo2Hi, hi2Lo, random.
    • Initialize the first array, lo2Hi, with values 1.0, 2.0, …, NUM_ELEMENTS
    • Initialize the second array, hi2Lo with values NUM_ELEMENTS, 24.0,…, 1.0
    • Initialize the third array, random, with random double values between 0.0 and less than 1.0
    • call the selectionSort method using each array. (Note: you might want to print the array elements themselves for debugging purposes when NUM_ELEMENTS is small, but you’ll not want to print them with larger values for NUM_ELEMENTS.)
  • Run your program three times with different values for NUM_ELEMENTS: 1000, 2000 and 4000.

In your submission write some text describing the relationship between the number of comparisons of the various values of NUM_ELEMENTS. For example, what do we find if we divide the number of comparisons for 2000 elements by the number of comparisons for 1000 elements? What do we find if we divide the number of comparisons for 4000 elements by the number of comparisons for 2000 elements?

SELECTION SORT FILE MUST USE THIS IN PROGRAM!!! PLEASE

public class SelectionSort {
/** The method for sorting the numbers */
public static void selectionSort(double[] list) {
for (int i = 0; i < list.length - 1; i++) {
// Find the minimum in the list[i..list.length-1]
double currentMin = list[i];
int currentMinIndex = i;

for (int j = i + 1; j < list.length; j++) {
if (currentMin > list[j]) {
currentMin = list[j];
currentMinIndex = j;
}
}

// Swap list[i] with list[currentMinIndex] if necessary;
if (currentMinIndex != i) {
list[currentMinIndex] = list[i];
list[i] = currentMin;
}
}
}
}

In: Computer Science

Write a Python program called “exam.py”. The input file, “input.txt”, is given to you in the...

  1. Write a Python program called “exam.py”. The input file, “input.txt”, is given to you in the Canvas exam instructions.
  2. Name your output file “output.txt”.
  3. Ensure the program consists of a main function and at least one other function.
  4. Ensure the program will read the input file, and will output the following information to the output file as well as printing it to the screen:
  • output the text of the file to screen
  • output the number of words in the file
  • output the number of sentences in the file
  • output the first sentence in the file
  • output the last sentence in the file
  • output the length of the first sentence
  • output the length of the last sentence
  • output the first word in the file
  • output the first letter in the file
  • output the last word in the file
  • output the last letter in the file

The input file, “input.txt” is called parse Text.txt

Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we can not dedicate — we can not consecrate — we can not hallow — this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us — that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion — that we here highly resolve that these dead shall not have died in vain — that this nation, under God, shall have a new birth of freedom — and that government of the people, by the people, for the people, shall not perish from the earth.

In: Computer Science