Questions
Write a class named Rat (to simulate rational or fraction number) such that it works as...

Write a class named Rat (to simulate rational or fraction number) such that it works as in the main below.

int main()

{

Rat a(3, 4), b(1, 2);

a.print(); // output: 3/4

b.print(); // output: 1/2

Rat c = a.add(b);

c.print(); // output: 5/4

// Hint: 3/4 + 1/2 = 6/8 + 4/8 = 10/8 = 5/4

Rat d = a.multiply(b);

d.print(); // output: 3/8

// Hint: 3/4 x 1/2 = 3/8

return 0;

}

In: Computer Science

paper prototype for laundry delivery and pick up app

paper prototype for laundry delivery and pick up app

In: Computer Science

Modify your program from Learning Journal Unit 7 to read dictionary items from a file and...

Modify your program from Learning Journal Unit 7 to read dictionary items from
a file and write the inverted dictionary to a file. You will need to decide on
the following:

    * How to format each dictionary item as a text string in the input file.
    * How to convert each input string into a dictionary item.
    * How to format each item of your inverted dictionary as a text string in
      the output file.

Create an input file with your original three-or-more items and add at least
three new items, for a total of at least six items.

------------------------------------------------------------------------------------------------------------------

The Unit 7 program:

Dr_Appointments = {'Mom':[2, 'April', 2020], 'Brother':[6, 'July', 2020], 'Sister':[6, 'January', 2021], }

def invert_dict(d):
inverse = dict()
for key in d:
    val = d[key]
    for val in val:
      if val not in inverse:
        inverse[val] = [key]
      else:
        inverse[val].append(key)
return inverse

print('Dr. Appointments:', Dr_Appointments)

print('Inverted Dr. Appointments:')
Invert_Appointments = invert_dict(Dr_Appointments)
print(Invert_Appointments)

This is the expanded dictionary: the Unit 7 plus three more:

Mom: 2, April, 2020,
Brother: 6, July, 2020,
Sister: 6, January, 2021,
Aunt: 2, December, 2021,
Uncle: 6, November, 2021,
Niece: 2, December, 2020

In: Computer Science

One of the benefits of having our data structures be generalized to hold any type of...

One of the benefits of having our data structures be generalized to hold any type of data is that we can have data structures store instances of data structures. As we mentioned in class, a priority queue is a queue where entries are added (enqueued) according to their priority level (and in order when priority is tied). So the entry with the highest priority that was added to the priority queue the earliest would be at the front and would be the entry that is removed (dequeued).

Given that entries with the same priority will have to be organized in the order they were enqueued (first-in, first out), one possible option is to create a PriorityQueue that holds Queue objects. At the top level, the PriorityQueue can organize entries according to priority level and ensure that the separate priority groups are maintained in their proper order. At the next level, each component Queue would be responsible for all of the entries with the same priority level, and can maintain them in the order in which they were enqueued.

For this problem, assume that there are only 5 priority levels (1 = very low; 2 = low;
3 = medium; 4 = high; 5 = very high). Give a detailed description of how you could implement the PriorityQueue as described above. Your answer should include:

  •  How the top-level organization would work.

  •  What properties your class would need.

  •  A short description of how each of the three main queue operations (enqueue, dequeue,

    and getFront) would work.

In: Computer Science

The header of a Python function is shown below: def result(one, two, three = 3, four)...

The header of a Python function is shown below:

def result(one, two, three = 3, four)

(a) How do we call the situation with the third parameter in this header?

(b) Indicate the method of correspondence between formal and actual parameters

that is used in the following function call:

result(four = 14, two = 22, one = 1, three = 33)

(c) Explain what is wrong with the following function call:

result(14, four = 44, 2, 3)

In: Computer Science

how docker provides an isolated workspace to keep applications on the same host or cluster isolated...

how docker provides an isolated workspace to keep applications on the same host or cluster isolated from one another

In: Computer Science

Consider the following statement: When designing a data structure, it is important to distinguish between what...

Consider the following statement: When designing a data structure, it is important to distinguish between what the characteristics and operations of the data structure are versus how they can be implemented.

(a) Explain why defining the ADT as a Java interface and defining classes to implement the interface is consistent with the above statement.

(b) Describe how the setup in part (a) is an example of polymorphism and provide a specific example of how polymorphism can be used to make our designed data structures more useful.

(c) Provide two (2) examples of how the specifications of the Java interface can enforce rules about how a data structure behaves. Be specific and explain your answer.

(d) Provide three (3) examples of how implementation-level decisions allowed a particular implementation to improve the runtime efficiency of an operation. Be specific and explain your answer.

In: Computer Science

What is a software Requirement? Explain types of requirements?

  1. What is a software Requirement? Explain types of requirements?

In: Computer Science

Using pipes for inter-process communications, write a C program to produce a parent/child relationship in which...

Using pipes for inter-process communications, write a C program to produce a parent/child relationship in which the parent process repeatedly counts and displays on the screen the number of characters for any user password the child process inputs to the pipe. The communications should cease once the string “Done” is inputted.

In: Computer Science

The title of the course is ARTIFICIAL INTELLIGENCE AND EXPERT SYSTEMS I. All answers should be...

The title of the course is ARTIFICIAL INTELLIGENCE AND EXPERT SYSTEMS I. All answers should be based on that. Please do not copy and paste answers on chegg or on google for me. All answers should be based on your understanding on the course. Please try as much to answer the questions based on what is asked and not setting your own questions and answering them. Let it be if you want to copy and paste answers.

*********************************************************************************************************************************************************************************************************************

9(A). AI is highly objective in decision making as it analyzes based on purely
gathered data. However, human’s decision may be influenced by
subjective elements which are not based on figures alone. You are hereby
requested to analyze (in ten points) the concept of ‘objectivity’ and
‘subjectivity’ in relation to data gathering in the statement given; for
Human Teller and Automated Teller machines (ATM).


(b)AI often produces accurate results as it functions based on a set of
programmed rules. As for human intelligence, there is usually a room for
“human errors” as certain details may be missed at one point or the other.
Justify in ten points how you can relate the statement to decision making
algorithms.

(c) The human brain uses about 25watts while modern computers only
generally use 2 watts in normal information processing. If this normality
becomes the other way instead, give in five points what could be the
reasons in each case of swap.

In: Computer Science

) Simplify the following Boolean functions by first finding the essential prime implicants (Please indicate the...

) Simplify the following Boolean functions by first finding the essential prime implicants (Please indicate the essential prime implicants and prime implicants): (a) F(w, x, y, z) = S(0, 1, 2, 4, 5, 6, 8, 10, 13, 15) (b) F(w, x, y, z) = wy’ + xy + y’z + w’xz

In: Computer Science

Next month there will a marathon. Ali, Mustafa, Ahmad, and Sami are friends and preparing for...

Next month there will a marathon. Ali, Mustafa, Ahmad, and Sami are friends and preparing for it. Each day of the week, they run a certain number of miles and write them into a notebook. At the end of the week, they would like to know the number of miles run each day, the total miles for the week, and average miles run each day.

Write a program to help them analyze their data. Your program must contain:

  • parallel arrays: an array to store the names of the runners and
  • a two-dimensional array of 4 rows and seven columns to store the number of miles run by each runner each day.
  • then implement the following functions:
    • a function to read and store the runners’ names and the numbers of miles run each day;
    • a function to find the total miles run by each runner and the average number of miles run each day

a function to output the results

In: Computer Science

1)  What kind of role does the project manager plays when entering the execution phase of a...

1)  What kind of role does the project manager plays when entering the execution phase of a project? Is planning still a concern or is it strictly monitoring and controlling at this point? Please explain.

In: Computer Science

1. Copy the files from Assignment 1 to Assignment 2. Relabel as necessary 2. Create 3...

1. Copy the files from Assignment 1 to Assignment 2. Relabel as necessary

2. Create 3 instances of the PetFoodCompany class - dogFoodMaker, catFoodMaker, fishFoodMaker.

3. Internally set the division name for each instance. (I.E. "Alpo" for dogFoorMaker, "Purina" for CatFoodMaker, "GloFish" for fishFoodMater)

4. Prompt me to enter the Company Name and Quarter only once.

5. For each of the above instances, prompt me for total sales and total expenses. A loop is not expected.

6. For each instance of the class, display the Company Name, Quarter. Division Name, Total Sales, Total Expenses and Net Income. The company name and quarter should be displayed for all instances.

5 Points Extra Credit: Create a method in the PetFoodCompany class that will do step 6 and call it from main() for the 3 instances.

Here is the code:

PetFoodComp.h:

class PetFoodCompany
{
public:
  
PetFoodCompany();

char getQuart();
char* getCompany();
char* getDivision();

void setQuart(char quart);
void setTotalSales(float totalSales1);
void setTotalExpences(float totalExpences1);
void setCompany(char name[]);
void setDivision(char name1[]);


float getTotalSales();
float getTotalExpences();

double netIncome();
  

private:
  
char company[40];
char division[40];

static char quart;
static double BonusRate;

float totalSales;
float totalExpences;
  
  
};

PetFood.cpp:

#include <iostream>
#include <cstring>
#include "PetFoodComp.h"

using namespace std;


double PetFoodCompany::BonusRate = 0.02;
char PetFoodCompany::quart = '1';

PetFoodCompany::PetFoodCompany()
{
   strcpy(company, "myCompanyName");
}

char PetFoodCompany::getQuart()
{
   return quart;
}

float PetFoodCompany::getTotalSales()
{
   return totalSales;
}

float PetFoodCompany::getTotalExpences()
{
   return totalExpences;
}

char* PetFoodCompany::getCompany()
{
   return company;
}

char* PetFoodCompany::getDivision()
{
   return division;
}

void PetFoodCompany::setQuart(char quart1)
{
   if (quart1 == '1' || quart1 == '2' || quart1 == '3' || quart1 == '4')
       quart = quart1;
}

void PetFoodCompany::setTotalSales(float totalSales1)
{
   totalSales = totalSales1;
}

void PetFoodCompany::setTotalExpences(float totalExpences1)
{
   totalExpences = totalExpences1;
}

void PetFoodCompany::setCompany(char name[])
{
   strcpy(company, name);
}

void PetFoodCompany::setDivision(char dname[])
{
   strcpy(division, dname);
}

double PetFoodCompany::netIncome()
{
   return (totalSales - totalExpences);
}

PetFoodMain.cpp:

#include <iostream>
#include <cstring>
#include "PetFoodComp.h"


using namespace std;

int main()
{
   double totalSales, totalExpences;
   PetFoodCompany pet;
   cout << "Company Name is " << pet.getCompany() << "\n";
   cout << "Current Quarter is " << pet.getQuart() << "\n";


   cout << "Enter Total Sales: ";
   cin >> totalSales;

   cout << "Enter Total Expences: ";
   cin >> totalExpences;

   pet.setTotalExpences(totalExpences);
   pet.setTotalSales(totalSales);

   cout << "Net Income: " << pet.netIncome() << "\n";

   return 0;
}

In: Computer Science

write a program in Java that can take a given text file and then compress it...

write a program in Java that can take a given text file and then compress it with Huffman coding due 20 october 2020

Huffman coding can be used to “zip” a text file to save space. You are required to write a program in Java that can take a given text file and then compress it with Huffman coding. Your program should be able to decompress the zipped files as well [4 marks]. In addition, show percentage gain in data compression i.e., how much space is saved [2 marks].

Compare the effectiveness of your Huffman code with 7-zip and WinZip softwares. You will get a bonus mark if you enhance the existing Huffman code somehow to have a better file compressor. It can also be published as a research article.

Correct Implementation: read about FileOutputStream, FileInputStream, FileReader etc to read/write to a binary file. You may use Integer.parseInt(huffmanCodeAsString,2) to store encoded Huffman code into a binary file. Huffman encoding should convert a text file to a binary file then decoding should convert the binary file back to a text file.

Please provide all java code. Be clear as possible when you paste the code so that it works in my pc  

Use netbeans IDE.

In: Computer Science