Please write a java program that has the following methods in it: (preferably in order)
Design Notes:
Please copy the java code along with a screen print (snippet) of the final output. I would like both to review the work that I already have done. Thanks in advance!
In: Computer Science
A company pays its salespeople on a commission basis. The salespeople are paid $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of merchandise in a week is paid $200 plus 9% of $5000, for a weekly pay of $650.
Create an application that uses a for loop to input each sales person’s gross sales for the week, and calculates and displays that sales person’s weekly pay. Process one sales person’s figures at a time. In the end, print out the weekly total sales and total pay for all company salespeople. All output values should be labeled and formatted to include a dollar sign and two decimal digits (i.e., dollars and cents). Skip lines in the output to separate data for each person and to separate the totals from the individual data.
Here is a pseudocode definition of the program requirements:
Initialize variables used to accumulate company totals for sales and weekly pay
Prompt the user to enter the number of salespersons to be processed
For each salesperson
Prompt the user to enter the weekly sales for that person Calculate and display and display the weekly pay for that person
Update variables used to accumulate company totals for sales and weekly pay
Display company totals for sales and weekly pay
Here is a sample test run of the application: sales commission calculator
Enter the number of salespersons: 2
Enter sales in dollars for sales person 1: 5000
Weekly pay is $650.00
Enter sales in dollars for sales person 2: 7500
Weekly pay is $875.00
Total weekly sales: $12500.00
Total weekly pay: $1525.00
THIS IS IN PYTHON
In: Computer Science
The assignment is to write a class called data. A Date object is intented to represent a particuar date's month, day and year. It should be represented as an int.
-- write a method called earlier_date. The method should return True or False, depending on whether or not one date is earlier than another. Keep in mind that a method is called using the "dot" syntax. Therefore, assuming that d1 and d2 are Date objects, a valid method called to earlier_date would be
>>> d1.earlier_date(d2)
and the method should return True if d1 is earlier than d2, or False otherwise. For example:
>>> today = Date(1,23,2017)
>>> y2k.earlier_date(today)
True
>>> today.earlier_date(mlk_day)
False
>>> feb_29.earlier_date(march_1)
True
python 2.7.13
In: Computer Science
index |
1 |
2 |
3 |
4 |
5 |
6 |
data |
11 |
10 |
21 |
3 |
7 |
5 |
In: Computer Science
For all algorithm design problems, part of the grade depends on efficiency. For every graphG = (V,E), the vertex set is {1,2,··· ,n}. We use n to denote the number of vertices and m to denote number of edges. Unless otherwise stated, all graphs are represented as adjacency lists. Each problem is worth 40 points.
Giveanalgorithmthat,givenanundirectedgraphGandnodes,createsanarrayShortestCountin which ShortestCount[i] is the number of shortest paths from s to vertex i. Provide a proof by induction that your algorithm is correct. Derive its runtime.
(Tip: Start with the BFS algorithm as given in the text, in which nodes are organized into layers Li based on distance from s, and update the counts as you build the tree.)
In: Computer Science
USING PYTHON 3.7:
import Student as st
import random
THRESHOLD = 0.01
tests = 0
passed = 0
def main():
test_get_higher_grade_student()
test_is_grade_above()
test_get_students()
test_get_classlist()
# test_count_above()
# test_get_average_grade()
print("TEST RESULTS:", passed, "/", tests)
def test_get_higher_grade_student():
s1a = st.Student("V0002000", 89)
s1b = st.Student("V0002001", 89)
s2 = st.Student("V0002002", 67)
s3 = st.Student("V0002002", 97)
result = get_higher_grade_student(s1a,s1b)
print_test("get_higher_grade_student(s1a,s1b)", result
== s1a)
result = get_higher_grade_student(s1a,s2)
print_test("get_higher_grade_student(s1a,s1b)", result
== s1a)
result = get_higher_grade_student(s1a,s3)
print_test("get_higher_grade_student(s1a,s1b)", result
== s3)
# (Student, Student -> bool)
# returns the Student with higher grade of s1 and s2, or s1
if grades are equal
def get_higher_grade_student(s1, s2):
print("fix me")
# TODO: complete get_higher_grade_student
# this should not always return s1
return s1
def test_is_grade_above():
s1 = st.Student("V0002000", 89)
s2 = st.Student("V0002002", 67)
result = is_grade_above(s1, 89)
print_test("is_grade_above(s1, 89)", result ==
False)
result = is_grade_above(s1, 88)
print_test("is_grade_above(s1, 89)", result ==
True)
result = is_grade_above(s2, 50)
print_test("is_grade_above(s2, 50)", result ==
True)
result = is_grade_above(s2, 80)
print_test("is_grade_above(s2, 80)", result ==
False)
# (Student, int -> bool)
# returns True if the grade of Student s is above the given
integer
def is_grade_above(s, n):
print("fix me")
# TODO: complete is_grade_above
def test_get_students():
result = get_students('studentData.txt')
expected = [st.Student('V00123456',
89),st.Student('V00123457', 99),
st.Student('V00123458', 30),st.Student('V00123459',
78)]
print_test("result = get_students('studentData.txt')",
result == expected)
# (str -> (list of Student))
# creates a new list of Students from data in the file
named filename
# where each line of file has a sid and grade separated by a
comma
def get_students(filename):
print("fix me")
# TODO: complete get_students
def test_get_classlist():
students = []
result = get_class_list(students)
expected = []
print_test("result = get_classlist(students)", result
== expected)
students = [st.Student('V00123456',
89),st.Student('V00123457', 99),
st.Student('V00123458', 30),st.Student('V00123459',
78)]
result = get_class_list(students)
expected =
['V00123456','V00123457','V00123458','V00123459']
print_test("result = get_classlist(students)", result
== expected)
# ((list of Student) -> (list of str))
# returns a new list of Students ids for each Student in
students
def get_class_list(students):
print("fix me")
# TODO: complete get_classlist
# TODO:
# Design and test a function that will take a list of
Students
# and a grade and counts and return the number of Students
# who have a grade above the given grade
# TODO:
# Design and test a function that will take a list of
Students
# computes and returns the average grade of all Students in
students
# (str, bool -> None)
# prints test_name and "passed" if expr is True otherwise prints
"failed"
def print_test(test_name, expr):
global tests
global passed
tests += 1
if(expr):
print(test_name + ': passed')
passed += 1
else:
print(test_name + ': failed')
# The following code will call your main function
# It also allows our grading script to call your main
# DO NOT ADD OR CHANGE ANYTHING PAST THIS LINE
# DOING SO WILL RESULT IN A ZERO GRADE
if __name__ == '__main__':
main()
studentData.txt ->
V00123456, 89
V00123457, 19
V00123458, 30
V00123459, 78
-------------------------//---------------------------//-----------------------------//-----------------------
class Student:
# constructor
def __init__(self, sid, grade):
self.sid = sid
self.grade = grade
def __str__(self):
return self.sid + ':' + str(self.grade)
def __repr__(self):
return str(self)
def get_sid(self):
return self.sid
def get_grade(self):
return self.grade
def set_sid(self, sid):
self.sid = sid
def set_grade(self, grade):
self.grade = grade
def __eq__(self, other):
if self.sid == other.get_sid():
return True
else:
return False
def main():
print('exercise1')
s1 = Student('V00123456', 90)
print(s1)
s2 = Student('V00456789', 60)
list = [s1,s2]
print(list)
result = s1.get_sid()
print(result)
result = s1.get_grade()
print(result)
s1.set_grade(98)
s1.set_sid("V00222210")
print(s1)
s1 = Student("V0002000", 89)
print(s1)
s2 = Student("V0002000", 67)
print(s2)
s3 = Student("V0002001", 67)
print(s3)
print(s1 == s2)
print(s1 == s1)
print(s1.__eq__(s2))
print(s2.__eq__(s3))
s1a = Student("V0002000", 89)
s1b = Student("V0002020", 65)
#
s2a = Student("V0002000", 67)
s2b = Student("V0002020", 65)
#
list1 = [s1a,s1b]
list2 = [s2a,s2b]
list3 = [s1a,s2a]
#
print('list1==list1', list1==list1)
print('list1==list2', list1==list2)
print('list1==list3', list1==list3)
main()
In: Computer Science
What is the subnet address for a host with the IP address 200.0.0.26 /29
200.0.0.8 |
||
200.0.0.12 |
||
200.0.0.20 |
||
200.0.0.24 |
||
20.0.0.16 |
In: Computer Science
Write a java method that takes a string and returns an array of int that contains the corresponding alphabetic order of each letter in the received string:
An illustration:
the method takes: "Sara"
the method returns: {4,1,3,2}
another illustration:
the method takes: "hey"
the method returns: {2,1,3}
In: Computer Science
Matlab question:
1. Implement image filtering in frequency domain on the "testtpattern512.tif" image. You will design the filter, and filter the image in the frequency domain, then use inverse DFT to display the filtered image in the spatial domain. Assume zero padding for filtering process.
a- Design a rectangular ideal low pass filter with a cutoff frequency of (Uo, Vo), filtering the image so that the vertical lines are blurred together, horizontal lines are basically intact and the letters are still readable. Uo, and Vo represent the cutoff frequencies in two dimensions. You may need to try different Uo, Vo, to find the best settings.
b- Design a Gaussian low pass filter with cutoff frequency of radius (sigma) Do, so that in the filtered image the large letter ‘a’ is barely readable, the other letters are not. You may need to try different Uo, to find the best settings. Please compute mean square error (MSE) between the original image and resulted blurred image for five Uo settings, sort them and explain why MSE decreases along with the increase of Do.
c- Design a Fifth-order Butterworth high pass filter, use circular cutoff, Do, so that only edges of shapes are clearly shown. You may need to try different Uo, to find the best settings. Please compute mean square error (MSE) between the original image and resulted image for five Uo settings, sort them and explain why MSE increases along with the increase of Do.
In: Computer Science
The Sieve of Eratosthenes is “a simple, ancient algorithm for finding all prime numbers up to any given limit,”
Write a method called sieve that takes an integer parameter, n, and returns a boolean array that indicates, for each number from 0 to n - 1, whether the number is prime.
In Java
In: Computer Science
build a python program that will be performing:
- Read a CSV file 'annual.csv' enterprise into a data structure
- Count the number of rows and columns
- Determine if the data contains empty values
- Replace the empty values by 'NA' for strings, '0' for decimals and '0.0' for floats
- Transform all Upper case characters to Lower case characters
- Transform all Lower case characters to Upper case characters
- save back the 'repaired' array as csv
- Print out the size of the data (number of rows, number of columns)
Difficulty:
-- be sure that each row has the same length (number of elements)
- the length of each row should be the same as the header.
In: Computer Science
USE R-studio TO WRITE THE CODES!
# 2. More Coin Tosses
Experiment: A coin toss has outcomes {H, T}, with P(H) = .6.
We do independent tosses of the coin until we get a head.
Recall that we computed the sample space for this experiment in class, it has infinite number of outcomes.
Define a random variable "tosses_till_heads" that counts the
number of tosses until we get a heads.
```{r}
```
Use the replicate function, to run 100000 simulations of this
random variable.
```{r}
```
Use these simulations to estimate the probability of getting a head
after 15 tosses. Compare this with the theoretical value computed
in the lectures.
```{r}
```
Compute the probability of getting a head after 50 tosses. What do
you notice?
```{r}
In: Computer Science
(4 pts) What does the function fun print if the language uses static scoping? What does it print with dynamic scoping?
x: integer <-- global procedure
Assignx(n:integer)
x:= n
proc printx
write_integer(x)
proc foo
Assignx(1)
printx
procedure boo
x: integer
Assignx(2)
printx
Assignx(0)
foo()
printx boo()
printx
In: Computer Science
Q.4. A) How Data Dissemination in Vehicular Ad hoc Networks (VANETs) is achieved?
In: Computer Science
Write a class Electionresults. Write the input inData (int a, int b) that creates (for example by random method) polls and returns two-dimensional arrays containing polls, where as the first dimension is the number of a political party and the second dimension is the constituency code.
The inData entry method includes integers, number of categories and number of constituencies. Write the program countingCategory that includes a two-dimensional state with data on the number of votes, and returns the total number of votes of each political party nationally in a one-dimensional state.
Write a main function that is a test tool that tries inData and countingCategory separately. a and b should be just some numbers doesn't matter, but numbers for political party (a) and numbers for constituency code(b). The beginning of the program should look something like this:
public class Electionresults {
public static int [] [] inn Data (int a, int b) {
}
public static int [] count Category (int [] [] tolur) {
}
public static invalid primary (String [] argument) {
}
}
In: Computer Science