In: Computer Science
Solve the problem.
The State Association of Retired Teachers has recently taken flak
from some of its members regarding the poor choice of the
association's name. The association's by-laws require that more
than 60 percent of the association must approve a name change.
Rather than convene a meeting, it is first desired to use a sample
to determine if meeting is necessary. Suppose the association
decided to conduct a test of hypothesis using the following null
and alternative hypotheses:
H0: p = 0.6
HA: p > 0.6
Define a Type II Error in the context of this problem.
A.They conclude that more than 60% of the association wants a name change when, in fact, that is not true.
B.They conclude that exactly 60% of the association wants a name change when that is, in fact, true.
C.They conclude that more than 60% of the association wants a name change when that is, in fact, true.
D.They conclude that exactly 60% of the association wants a name change when, in fact, that is not true.
why is A wrong? which is correct?
In: Statistics and Probability
In: Computer Science
Please, how to construct a class template in Python?
Class name is animal:
give it a set of class variables called: gender, status
give it a set of class private variables: __heart, __lungs, __brain_size
construct methods to write and read the private class variables
in addition initiate in the constructor the following instance variables: name, location as well as initiate the variables status and gender all from constructor parameters
The variables meaning is as follows:
name is name
status is wild or domestic
location is location
gender is gender (M/F)
Private variables have all values Yes or NO only __brain_size should be a number
Be sure to provide a check on every variable that requires it.. Yes/No variables can only get values Yes/NO, Numeric variables only number. The rest does not need a check.
Finally provide a method that will print the class state on the output such as
Animal Name: Name
Animal Location: location
etc (print all parameters with the appropriate description)
All variables that you are initializing will depend on the user
In: Computer Science
convert this code to Python and make sure you use chained map and filter as well.
https://book.pythontips.com/en/latest/map_filter.html
CODE BELOW IS IN JAVASCRIPT
let people = [
{name: "Amy", pounds_weight: 152, inches_height: 63},
{name: "Joe", pounds_weight: 120, inches_height: 64},
{name: "Tom", pounds_weight: 210, inches_height: 78},
{name: "Jim", pounds_weight: 180, inches_height: 68},
{name: "Jen", pounds_weight: 120, inches_height: 62},
{name: "Ann", pounds_weight: 252, inches_height: 63},
{name: "Ben", pounds_weight: 240, inches_height: 72},
];
//functions to convert pounds to kg and inches to meters
let poundstokg = (pounds)=> pounds * 0.453592;
let inchestometers = (inches)=> inches * 0.0254;
//add bmi function
let addbmi = (person) => {
person["bmi"] =
poundstokg(person["pounds_weight"])/(inchestometers(person["inches_height"])
* inchestometers(person["inches_height"]));
return person;
}
//checks if the person is overweight
let isOverweight = (person) => (person["bmi"] >= 25.0
&& person["bmi"] < 30);
//checks if the person is obese
let isObese = (person) => (person["bmi"] >= 30);
// array of overweight and obese people
let overweight_people =
people.map(addbmi).filter(isOverweight);
let obese_people = people.map(addbmi).filter(isObese);
console.log(overweight_people);
console.log(obese_people);
In: Computer Science
JAVA
In this PoD you will use an ArrayList to store different pet names (there are no repeats in this list). This PoD can be done in your demo program (where your main method is) – you don’t have to create a separate class for today.
Details
Create an arraylist of Strings, then using a Scanner object you will first read in a number that will tell you how many pet names (one word) you will add to the arraylist.
Once you have added all the names, print the list.
Then read in one more pet name. If this is pet name already exists, do nothing, but if the pet name isn’t in the list, add it to the front of the list (e.g., the first position).
Print the list again.
Next read in two more pet names. If the first pet name is in the list, replace it with the second pet name. If the first pet name isn’t in the list, add the second pet name to the end of the list.
Print the list again.
Input
Example Input:
5 Whiskers Benji Lassie Smokey Bob Triffy Bob Max
Output
Example Output:
[Muffin, Benji, Snowball, Fluffy]
[Muffin, Benji, Snowball, Fluffy]
[Muffin, Benji, Snowball, Whiskers, Fluffy]
In: Computer Science
In the second task, you will write a Java program that validates an input to see whether it matches a specified pattern. You will have to read a bit about regular expressions for this Lab.
1. Prompt the user to enter the email address.
2. Read the user input as a String.
3. A regular expression that specifies the pattern for an email address is given by “[a-zA-Z0- 9.]++@[a-zA-Z]++.(com|ca|biz)”. Use this as the input to the matches method in the String class and output the result returned by the method.
4. Prompt the user to enter the full name.
5. Full name should have First name, zero or Middle names and the Last name. For this purpose, we will assume a name (first, middle or last) is a set of characters without any spaces. Some examples are “John”, “McDonald”, “smiTh”. The names are separated by exactly one space. Write a regular expression to represent this pattern.
6. Use the matches method in the String class to validate the name entered by the user and output the result returned by the method.
A possible dialogue with the user might be;
Please enter the email address: [email protected]
true
Please enter the full name: Malaka Second Third Walpola
true
In: Computer Science
Using Classes
This problem relates to the pre-loaded class Person.
Using the Person class, write a function print_friend_info(person) which accepts a single argument, of type Person, and:
Write a function create_fry() which returns a Person instance representing Fry. Fry is 25 and his full name is 'Philip J. Fry'
Write a function make_friends(person_one, person_two) which sets each argument as the friend of the other.
class Person(object):
def __init__(self, name, age, gender):
"""Construct a person object given their name, age and gender
Parameters:
name(str): The name of the person
age(int): The age of the person
gender(str): Either 'M' or 'F' for male or female
"""
self._name = name
self._age = age
self._gender = gender
self._friend = None
def __eq__(self, person):
return str(self) == str(person)
def __str__(self):
if self._gender == 'M':
title = 'Mr'
elif self._gender == 'F':
title = 'Miss'
else:
title = 'Ms'
return title + ' ' + self._name + ' ' + str(self._age)
def __repr__(self):
return 'Person: ' + str(self)
def get_name(self):
"""
(str) Return the name
"""
return self._name
def get_age(self):
"""
(int) Return the age
"""
return self._age
def get_gender(self):
"""
(str) Return the gender
"""
return self._gender
def set_friend(self, friend):
self._friend = friend
def get_friend(self):
"""
(Person) Return the friend
"""
return self._friend
In: Computer Science
ASSIGNMENT:
Write a program to ask for the name and test score for 8 students, validate that the test score is between 0.0 and 100.0 inclusive, and store the names and test scores in 2 parallel arrays. Then, calculate and display the average of the test scores. Finally, display all the students who have test scores above the average.
Example Run #1:
(bold type is what is entered by the user)
Enter student name #1: George
Enter the score for George: 90
Enter student name #2: Sam
Enter the score for Sam: 65
Enter student name #3: Billy
Enter the score for Billy: 123
The score entered for Billy was not in the range of 0.0 to
100.0.
Please re-enter the score for Billy: 83.5
Enter student name #4: Bob
Enter the score for Bob: -5
The score entered for Bob was not in the range of 0.0 to
100.0.
Please re-enter the score for Bob: 56.7
Enter student name #5: Phil
Enter the score for Phil: 83
Enter student name #6: Scott
Enter the score for Scott: 0
Enter student name #7: Suzanne
Enter the score for Suzanne: 73.4
Enter student name #8: Joe
Enter the score for Joe: 69
The average of the scores is xx.x%.
George has a score of 90.0, which is above average.
Billy has a score of 83.5, which is above average.
Phil has a score of 83.0, which is above average.
Suzanne has a score of 73.4, which is above average.
Joe has a score of 69.0, which is above average.
The example run shows EXACTLY how your program input and output will look.
C programming NO FLOATS
In: Computer Science
Program C You are given some data from an animal shelter, listing animals that they currently have. They have asked you to write a program to sort the dogs and cats in age in ascending order, respectively, and write them in separate files. Assume the input file has the format of name (one word), species (one word), gender (one word), age (int), weight (double), with each animal on a separate line:
Hercules cat male 3 13.4
Toggle dog female 3 48
Buddy lizard male 2 0.3 ….
Example input/output:
Enter the file name: animals.txt
Output file name: sorted_dogs.txt sorted_cats.txt
1. Name your program animals.c.
2. The output file name should be sorted_dogs.txt and sorted_cats.txt. Assume the input file name is no more than 100 characters.
3. The program should be built around an array of animal structures, with each animal containing information of name, species, gender, age, and weight. Assume that there are no more than 200 items in the file. Assume the name of an animal is no more than 100 characters.
4. Use fscanf and fprintf to read and write data.
5. Your program should include a sorting function so that it sorts the animals in age. You can use any sorting algorithms such as selection sort and insertion sort. void sort_animals(struct animal list[], int n);
6. Output files should be in the format of name gender age weight, with 2 decimal digits for weight.
For example,
Toggle female 3 48.01
Rocky male 5 52.32
In: Computer Science