Using Python Programming
PROBLEM 3 - OLD MACDONALD: Write a program to print the lyrics
of the song ”Old MacDonald”. Your program should print the lyrics
using five different animals (i.e., cow, sheep, dog, cat ,turkey)
using the example verse below. For this problem you are required to
write then make use of a function getVerse that takes two string
parameters: (1) the name of an animal and (2) the sound that animal
makes. The function should not print anything if the name of the
animal is not one of the five above, or if there is a mismatch
between the animal and the sound. In your program, call your
function 5 times, passing each time to the function a different
combination of animal name and sound. The five different animals and
their associated sounds are the followings:
Animal Sound
cow moo
sheep baaa
dog woof
cat meow
turkey gobble gobble
In: Computer Science
In: Computer Science
About Cache, computer organization, computer architecture, computer science.
Cache Question:
A[0] is at memory address 0x0FED CBA0. Array B[] is right after array A[] in the data memory.
Both arrays have 10 integers
Based on memory address for A[0] of 32 bits, i know that the cache index and tag is 27 bits, offset is 4 bits and index is 1 bit.
Q: Will the tag and cache index change for A[8] and B[8]? And how will it change?
I personally feel that tag and cache index will not change for A[8]. But i'm not too sure about B[8]
Q: Does the cache behaviour affect the A[8] and B[8]?
E.g. Direct mapped cache vs 2-way set-associative cache
In: Computer Science
IN JAVA, For this exercise, you will create your own example of using a generic method. First write a program that calls a method to multiply two integers and return the integer result. Then modify that program to make the method generic, calling it with two generic data types (T1 and T2) and then returning the result in the same type (also needs to be generic). Demonstrate your program by calling the method two times, once with an integer and once with a double. In your main program, display the results of the method call showing both an integer output and a decimal output. Submit code for both your original method (non-generic) and your revised method (generic), along with execution screenshots.
In: Computer Science
2. [9 pts] Write the code necessary to properly allocate memory (on the heap) in the following scenarios
a). An array a of n characters
b) An array b of m+n integers
c) An x × y × z matrix m1 of integers initialized to 0s
Use C code
In: Computer Science
Describe the actions taken by a kernel to context-switch between processes.
In: Computer Science
/*
*fix the below C Program to Display the Nodes of a Linked List in Reverse
*/
#include <stdio.h>
#include <stdlib.h>
struct node
{
int visited;
int a;
struct node *next;
};
int main()
{
struct node *head = NULL;
generate(head);
printf("\nPrinting the list in linear order\n");
linear(head);
printf("\nPrinting the list in reverse order\n");
display(head);
delete(head);
return 0;
}
void display(struct node *head)
{
struct node *temp = head, *prev = head;
while (temp->visited == 0)
{
while (temp->next != NULL && temp->next->visited == 0)
{
temp = temp->next;
}
printf("%d ", temp->a);
temp->visited = 1;
temp = head;
}
}
void linear(struct node *head)
{
while (head != NULL)
{
printf("%d ", head->a);
head = head->next;
}
printf("\n");
}
void generate(struct node **head)
{
int num, i;
struct node *temp;
printf("Enter length of list: ");
scanf("%d", num);
for (i = num; i > 0; i--)
{
temp = (struct node *)malloc(sizeof(struct node));
temp->a = i;
temp->visited = 0;
if (head == NULL)
{
head = temp;
head->next = NULL;
}
else
{
temp->next = head;
head = temp;
}
}
}
void delete(struct node **head)
{
struct node *temp;
while (head != NULL)
{
temp = head;
head = head->next;
free(temp);
}
}In: Computer Science
//using c fixing the error to make a correct print-out.
#include <stdio.h>
int main(void)
{
unsigned int a = 1000;
signed int b = -1;
if (a > b)
printf("%d is more than ", a);
printf("%d\n", b);
else
printf("%d is less or equal than ", a);
printf("%d\n", b);
return 0;
} In: Computer Science
Write a C program that defines
int minimum (int ji, int j2)
which returns the smaller of j1 and j2. (a) Write your program with a global variable for the actual parameter. Translate your C program to Pep/9 assembly language. (b) Write your program with a local variable for the actual parameter. Translate your C program to Pep/9 assembly language.
In: Computer Science
Convert an infix expression to its postfix representation in JAVA
In: Computer Science
Question: PROJECT 2 – ATM MACHINE For this project you will be building an ATM application that will allow ... PROJECT 2 – ATM MACHINE For this project you will be building an ATM application that will allow users to log in, deposit, withdraw, and check balance. Set a default beginning balance of $1000. I want all monies formatted to currency. Log in Usernames and passwords need to be stored in parallel arrays. At least three logins available for me. The user is allow only 3 attempts at password and it terminates The actual login will also be a method Deposit- must be a method Are they depositing cash, checks, or both (hint looping needed) If checks how many – hint looping After the user is finished with deposit you will show out the total of the deposit and the new balance Withdraw – must be a method After withdraw show amount withdrawn and new balance Check balance Show out current balance The program must loop until the user says they have not more transactions to make. THIS MUST BE IN C# Programming! Please also include the TryParse
In: Computer Science
In C++:
5) Suppose you have the following declaration:
struct student
{
string name;
int exams [5];
double average;
};
a) Declare a pointer to the structure student and use it to create a dynamic structure.
b) Ask the user to enter the name of a student and his 5 exam scores.
c) Calculate the average of the 5 exams and assign it to the average.
d) Delete the dynamic structure.
d) Create a dynamic array of 10 students.
e) Ask the user to enter the names of all student and their 5 exam scores.
f) For each student, calculate the average of the 5 exams and assign it to the average.
g) Delete the dynamic array.
6) Assume you have the following declaration (in main) :
int num[13] [7];
Assume that array num is filled completely. Write functions to perform each of the following:
a) A function that prints all elements in the array that are greater than 80 or less than 10.
b) A function that finds the largest number in the array and returns its subscript.
c) A function that finds and returns the average of all the numbers in the array.
d) A function that print the entire array in a neat table, but starting with the last row and proceeding in reverse order to the first.
7) Fill in the blanks to declare “Student’s” constructor taking two parameters and initializing its private members: names and dateOfBirth.
Student::Student( string x, Birthday bo)
___________: name (_______________) x,
dateOfBirth(bo) {
}
(answer is : for the first blank and x for the second blank)
In: Computer Science
implement merge sort,quick sort, and radix sort algorithms in java and test how long it will take to sort with random data sets of users input numbers.
In: Computer Science
Describe the compression/archive utilities listed below:
• 7-zip
• gzip
• rar
• tar
• zip
For each utility, do the following:
• Write a description of how the utility operates
• List the most common arguments & describe the
effect of that argument
• Briefly describe any compression algorithms
implemented by the utilities
Create a summary table that compares and contrasts the different utilities.
Cite any references you will use to create the paper (in APA format).
PLEASE don't copy from other Chegg answers. Thanks!
In: Computer Science
When data visualization should be used and why. Provide examples of reports or dashboards from real companies. Include links or screenshots of these reports.
In: Computer Science