b) The recent global climate change has necessitated the need for a new model for predicting weather patterns. Two scientists who were modeling this process in Ghana ended up with two different system models.
i) What could be the possible reason(s) for the differences in their system model? Justify your answer.
ii) In relation to real world data from the process how can you select the best model to employ for subsequent simulations and prediction of the process?
In: Computer Science
def binsearch(a):
if len(a) == 1:
return a[0]
else:
mid = len(a)//2
min1 = binsearch(a[0:mid])
min2 = binsearch(a[mid:len(a)])
if min1 < min2:
return min1
else:
return min2
What is the time complexity for the function? include derivative steps to your answer
In: Computer Science
Can you find any proofs or explanations that hash algorithms (such as MD5 and SHA1) are as good as they appear to be?
In: Computer Science
This solution is to be written in JAVA
It is difficult to make a budget that spans several years, because prices are not stable. If your company needs 200 pencils per year, you cannot simply use this year’s price as the cost of pencils two years from now. Because of inflation, the cost is likely to be higher than it is today.
The program asks for the cost of the item, the number of years from now that the item will be purchased, and the rate of inflation. The program then outputs the estimated cost of the item after the specified period. Have the user enter the inflation rate as a percentage, such as 5.6 (percent). Your program should then convert the percent to a fraction, such as 0.056, and should use a loop to estimate the price adjusted for inflation.
In: Computer Science
2,3,1
8,7,-3
1,2
Abc
0,4,3
-1,7,10
Develop a Python program which reads all the coefficient inputs from coeff.txt and find the “real” roots of the equations. The following requirements must be met:
In: Computer Science
Question 3 (1 mark) : Assume that your program has classes Family, House, LivingRoom, Bedroom,Bathroom, Kitchen. What is the most appropriate relationship among the above classes. Write a UML diagram that indicates your system architecture (classes and relationships).
In: Computer Science
In this exercise, you will create a basic data management system for students in the Department of Computer Science and Information Technology using the linked list.
You must write two classes – Student class attached, and StudentChart.
Student class consists of student data. StudentChart class contains a linked list of all students in the department.
For this purpose, you must fulfill the following interfaces (note - fields of the objects should be marked as private).
Class: Student chart
Class of Student Chart contains data for all students stored in a linked list. The way to add a student to the list by method addStudent only to the front of the list. At the beginning the student list is empty, the number of students enrolled in the Department is 0. Think what would be the fields of this class, so that you can know much information at any one time.
Constructors:
|
Creat the class chart according to the private |
|
|
StudentChart() |
.fields(variables). |
Methods:
|
Return type |
Method name and parameters |
operation |
|
Add student to the front of the linked list. |
||
|
void |
addStudent(Student student |
|
|
Delete student from the list. Do nothing if the student does not exist in the list. Returns false if student not found in the list |
||
|
boolean |
deleteStudent(Student student) |
|
|
int |
getNumOfStudents() |
Returns the number of students in the list. |
|
boolean |
isStudent(Student student) |
Examine if student exists in the list. |
|
Student |
getStudent(int studentNum) |
Returns students data for the students with studentNum. |
|
Returns the student average in the course with number |
||
|
double |
getAverage(int course) |
course |
|
Returns student average in all courses for all students. |
||
|
double |
getAverage() |
(You can use the Student class methods). |
|
Prints the students data for all students as follow: Student number 1: <Student String representation> Student number 2: <Student String representation> … Student number <n>: <Student String representation> If there are no students print: |
||
|
void |
printStudentChart() |
No students! |
It is recommended to write tester to present all the methods of the class and to check that they actually work.
The student class :
public class Student {
private String name;// student name
private long id; // student identity number
private int [] grades = new int[5]; // list of student courses grades
//costructor that initialize name and id
public Student(String name, long id){
String n = name.toUpperCase();
name = name.replace(name.charAt(0), n.charAt(0));
for(int i=0 ; i<name. length(); i++)
if(name.charAt(i)==' ')
name = name.replace(name.charAt(i+1), n.charAt(i+1));
this.name = name;
this.id=id;
}
//copy constructor
public Student(Student st){
this.name= st.name;
this.id = st.id;
}
//return the student name
public String getName(){
return name;
}
//returns the student id number
public long getId(){
return id;
}
// returns the course grade accoring to parameter course(course number)
public int getGrade(int course){
if(grades[course]== 0)
return -1;
return grades[course];
}
// set the name of student with parameter name
public void setName(String name){
String n = name.toUpperCase();
name = name.replace(name.charAt(0), n.charAt(0));
for(int i=0 ; i<name. length(); i++)
if(name.charAt(i)==' ')
name = name.replace(name.charAt(i+1), n.charAt(i+1));
this.name = name;
}
//sets the student id with parameter id
public void setId(long id){
this.id = id;
}
//set the course grade with parameter grade
public void setGrade(int course, int grade){
grades[course]= grade;
}
// set all the grades of the student from user
public void setGrades(int [] g){
for(int i=0; i< grades.length; i++)
grades[i]=g[i];
}
//returns the student average in his course
public double getAverage(){
int sum= 0;
int count =0;
for(int i=0; i< grades.length; i++){
if(grades[i]!=-1)
sum=+ grades[i];
count++;
}
return sum/count*1.0;// compute and return average
}
// takes a student object as a parameter and
// return true if it is the same as student parameter
public boolean equals(Student student){
if(student.id== this.id)
return true;
else
return false;
}
//returns a string that represents the student object
public String toString(){
String [] g = new String[5];
for(int i=0; i< grades.length; i++)
if(grades[i]!= -1)
g[i]= grades[i]+" ";
else
g[i]="no grade";
String n1= "Name:"+ name+"\n"+ "ID: "+ id +"\n"+ "Grades:"+"\n"+
"Introduction to Programming - "+g[0] +"\n"+"Introduction to Management – "+g[1]+"\n"+
"Data Structures – "+g[2]+"\n"+"Introduction to Economics – "+g[3]+"\n"+
"Introduction to Mathematics – "+g[4];
return n1;
}
}
In: Computer Science
public static BagInterface<String> intersection (BagInterface<String> bagA, BagInterface bagB)
This method must return a new bag which is the intersection of the two bags: bagA and bagB. An element appears in the intersection of two bags the minimum of the number of times it appears in either. For example, {1,1,2} ∩{1,1,2,2,3}= {1,1,2}. Do not forget to state the big Oof your method implementation.
two file java main and test
by netbeans java
data structure and algorithem
In: Computer Science
C Programming Language Question
The following program sums up a number from a user input argv[1] by using a single thread. For example, argv[1] of 100 is going to give us a sum of 5050 using just a single thread.
I need to modify it so that it takes 2 command lines args, argv[2] for number of threads. In other words, the program needs to use multi-threads to solve it. The number of threads is going to divide the work between them and then join together to sum the numbers.
For example, a command line of 100 10 will give us a sum of 5050 using 10 threads.
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
int sum; // this data is shared by the threads
void *runner(void *param); // threads call this
function
int main(int argc, char *argv[])
{
pthread_t tid; // thread identifier
pthread_attr_t attr; // set of thread attributes
// set the default attributes of the thread
pthread_attr_init(&attr);
// create the thread
pthread_create(&tid, &attr, runner, argv[1]);
// wait for the thread to exit
pthread_join(tid, NULL);
printf("Sum = %d\n", sum);
}
void *runner(void *param)
{
int i, upper = atoi(param);
sum = 0;
for (int i = 1; i <= upper; i++)
sum += i;
pthread_exit(0);
}
In: Computer Science
IN JAVA
Create an array and add random values to it, and then find the sum of the values using recursion.
In: Computer Science
Answer the following questions about computer operating systems:
1.
Which of the following conditions must exist for deadlock to occur?
Group of answer choices
All of these.
No preemption
Circular wait
Hold and wait
Mutual exclusion
2.
Which of the following is not a method for dealing with deadlock?
Group of answer choices
deadlock prevention
deadlock deletion
deadlock detection and recovery
deadlock avoidance
3.
A state where deadlock might occur is known as a(n) ________________.
Group of answer choices
safe state
dead state
unsafe state
critical state
4.
A resource allocation graph can indicate if deadlock might occur if there is a _______________ in the graph.
Group of answer choices
bear
cycle
detached subgraph
petri net
In: Computer Science
The best IT support technicians are the ones who continually teach themselves new skills. You can teach yourself to use and support Windows by using the web, a couple of apps in Windows 10 called Get Help and Tips, or the Windows Help and Support utility in Windows 8/7. To start the apps in Windows 10, type get help in the search box or type tips in the search box. In Windows 8, type Help and Support on the Start screen. In Windows 7, click Start and then click Help and Support. If you are connected to the Internet, clicking links can take you to the Microsoft website, where you can find information and watch videos about Windows.
Do the following to research a topic so you can become an independent learner about Windows:
1. The Windows 10/8/7 Snipping Tool can help you take screenshots of the Windows desktop. These screenshots are useful when documenting computer problems and solutions. Use Get Help or Windows Help and Support to find out how to use the Snipping Tool. Use it to take a screenshot of your Windows desktop. Save the screenshot into a file on a USB flash drive or on the hard drive. Print the file contents.
2. Access the support.microsoft.com website for Windows support. Save or print one article from the Knowledge Base that addresses a problem when installing Windows 10/8/7.
3. Search the web to learn the purpose of the pagefile.sys file. What website did you use to find your answer? Why is the Microsoft website considered the best source for information about the page file sys file?
In: Computer Science
In Real Problem 10-1, you installed VirtualBox and created a VM. In this project, you install Ubuntu Desktop, a popular Linux distro (short for distribution). Complete the following steps:
a. Go to ubuntu.com and download the Ubuntu Desktop OS to your hard drive. This is a free download, so you can decline to make any donations. The file that downloads is an ISO file. Ubuntu is a well-known version of Linux that offers both desktop and server editions.
b. Open VirtualBox. Select the VM and click Settings. In the VM’s Settings box, click Storage in the left pane. In the Storage Devices area, to the right of Controller: SATA, click the Adds optical drive icon, which looks like a disc with a green (+) symbol on it, as shown in Figure 10-59.
c. A dialog box appears. Click Choose Disk. Browse to the location of the ISO file that contains the Ubuntu desktop operating system setup files. Select the ISO file, click Open and then click OK. You will return to the Oracle VM VirtualBox Manager window.
d. With the VM selected, click Start on the toolbar. Your VM starts up and begins the process of installing the operating system. Click Install Ubuntu. Follow the prompts and accept all default settings. If given the option, don’t install any extra software bundled with the OS. You’ll need to restart the VM when the installation is finished. When prompted to remove the installation media, press Enter because the ISO file was automatically removed already.
e. In the welcome windows, read about Ubuntu and skip the Livepatch setup. Install any OS updates offered. Monitor the update by clicking the Software Updater app in the dock and restart when it’s ready. To verify that you have an Internet connection, open the Mozilla Firefox browser and surf the web.
f. Good IT technicians must know how to use many operating systems. Poke around in the Ubuntu desktop interface to get familiar with it. You can also search the web for tutorials videos on how to use Ubuntu Desktop. How do you open the Settings app to change settings in the OS, such as background-image, notifications, privacy, and network connections?
g. When you’re ready to shut down your VM, click the power icon in the upper-right corner of your screen, click the next power icon and click Power Off in the menu that appears. As with physical computers, it’s important to properly shut down the VM correctly to prevent the corruption of its OS and other files.
In: Computer Science
N/B: THE PROGRAMME SHOULD BE WRITTEN IN JAVA LANGUAGE
CS 202
Part 1.
Create a class called Loan. An instance of the class can be used to calculate
information about a bank loan.
The class should have the following methods:
a. A constructor that is passed the amount being borrowed, the annual interest
rate and the number of years for repayment.
b. A default constructor that initializes the amount being borrowed, the annual
interest rate and the number of years for repayment to 0.
c. "get" methods (accessors) for the loan amount, the annual interest rate and the
number of years for repayment.
d. "set" methods (mutators) for the loan amount, the annual interest rate and the
number of years for repayment.
e. A method that calculates and returns the amount of the monthly payment for
the loan.
The monthly payment on a loan can be calculated using the following formula:
loanAmount * R
monthly payment = --------------------
-N
1 - (1 + R )
R = monthly rate of interest for the loan
N = number of months to repay the loan
f. A method that returns the sum of all payments needed to repay the loan.
g. A method that returns the sum of all interest paid on the loan.
Part 2.
Write an application that tests the Loan class. The program should allow the user to
create a loan, enter information about the loan and make changes to the amount of
the loan, the interest rate, and the number of years to repay the loan.
In: Computer Science
C++(OOP)plz SOLVE THE PROBLEM ACCORDING TO
INSTRUCTIONS
Imagine you are on a trip around Europe and have collected
currencies from
the different countries that you have travelled.
You are to write a simple money counting program. Your program will
be able
to deal in the following three currencies
a) Pakistani Rupee
b) Turkish Lira
c) Pound Sterling
You must make a class called Currency. Create its data members
and any
member functions you require. Your class should be written such
that you
are able to execute statements like these in your main
function:
C_Sum =100 C1 + 11 (C2) + 56 (C3)
where C1, C2 and C3 represent different currency bank notes.
% C1 - displays C1 amount in all three currencies.
C1 [“pkr”]– displays the C1 amount in PKR along with the date and
current
exchange rate of the input currency with pkr.
C1 [“gbp”]– displays the C1 amount in Pound Sterling along with the
date and
current exchange rate between the input currency and pounds.
A FEW GUIDELINES
This question involves operator overloading and needs to be
accomplished using classes.
Your main function must be as small as possible. This implies you
must
use class constructors and class functions to accomplish everything
in assignment
Make a separate class called Conversion_Rate. Use constructors to
take
inputs for the exchange rate for the day. Display them every time
you
display the total sum.
Every time you perform a money conversion, your program must
contact
the Conversion_Rate class class to provide the exchange rates for
the
given day. You are to apply the concept of friend functions/
friend
classes (as you need) to allow this class to share its
information.
In: Computer Science