I asked this question before, but I'm wondering if there are any other ways to do this problem. My exam will be similar to this, so I'm looking for more examples to study with. Thank you!
For this Java program, you will write two classes: GradeCalculator and GradeCalculatorDriver.
In the GradeCalculator class, compute the final average and letter grade for a particular student.
The final average is calculated according to the following rules:
1) There are ten exams scored out of 100 points
2) The lowest exam score is not included in the calculation of the final average
3) The highest exam score is not included in the calculation of the final average
4) An average of 91-100 is an A
5) An average of 81-90 is a B
6) An average of 71-80 is a C
7) An average of 61-70 is a D
8) An average of 0-60 is an E
The GradeCalculator class must include the following methods:
1) A method to compute and return the highest score
2) A method to compute and return the lowest score
3) A method to compute the sum of all the scores
4) A method to compute the final average
5) A method to determine the letter grade
In the GradeCalculatorDriver class, include a main method that asks the user for the student’s name and their ten exam grades, reads the grades, calculates the letter grade and prints it. This process should be repeated until the user enters N.
For example, a run of the program might look something like this:
Welcome to Score Calculator
Want to compute a final average? Y
Please enter the student’s name: Sara Smith
Please enter test scores all on one line separated by one or more spaces.
The final score for Sara Smith is 100.
The letter grade for Sara Smith is A.
Want to compute another final average? N
In: Computer Science
Can you please Describe your actions as the Manager, and how you would manage the project team's stress levels? but meeting the required dates.
Can you please Describe in detail, how dealing with short deadlines??..... will need to be compensated in the teams focus ?as well as how you will ensure that this is accomplished?
***(G) Greenberg, Jerald and Baron, Robert, Behavior in
Organizations, 10th Edition, Prentice Hall, Upper Saddle River, NJ
2008. ISBN 9780136090199.
***(H) Humphrey, Watts S., Managing Technical People,
Addison-Wesley, Reading, MA 1997. ISBN 9780201545975
***Please use the book resource if you can ? and APA for another website resource,
*250 words response please!
In: Computer Science
Suppose we have a collection of n different subsets of the set { 1, 2, ..., n } and they are in some arbitrary order, that is, we have subsets S1, S2, ..., Sn, but how many and which elements are in each of these subsets is entirely arbitrary. Suppose also that we have another subset S' of { 1, 2, ..., n }.
(a) Express a brute-force algorithm that determines whether S' equal to one of the subsets in the collection.
(b) Give a big-O worst case estimate as a function of n for the time complexity of your algorithm. To receive full credit, you must explain how you obtained your answer.
In: Computer Science
def read_list():
"""
This function should ask the user for a series of integer values (until the user enters 0 to stop) and store all those values in a list. That list should then be returned by this function.
"""
def remove_duplicates(num_list):
"""
This function is passed a list of integers and returns a new list with all duplicate values from the original list remove.
>>> remove_duplicates([1, 2, 3, 2, 3, 4])
[1, 2, 3, 4]
>>> remove_duplicates([1, 1, 1])
[1]
>>> remove_duplicates([])
[]
"""
def main():
num_list = read_list()
print("Original list entered by user: ")
print(num_list)
no_duplicates = remove_duplicates(num_list)
print("List with duplicates removed: ")
print(no_duplicates)
In: Computer Science
C#
1. Create an Employee class with two fields: idNum and hourlyWage. The Employee constructor requires values for both fields. Upon construction, thrown an ArgumentException if the hourlyWage is less than 7.50 or more than 50.00. Write a program that establishes, one at a time, at least three Employees with hourlyWages that are above, below, and within the allowed range. Immediately after each instantiation attempt, handle any thrown Exceptions by displaying an error message. Save the file as EmployeeExceptionDemo.cs.
2. Write an application that creates an array of five Employees. Prompt the user for values for each field for each Employee. If the user enters improper or invalid data, handle any exceptions that are thrown by setting the Employee’s ID number to 999 and the Employee’s pay rate to the $7.50. At the end of the program, display all the entered, and possible corrected, records. Save the file as EmployeeExceptionDemo2.cs.
In: Computer Science
Write this in c++
Leap year and Second in year program
1. If a year is divisible by 4 with no remainder, it is a leap
year,
2. unless it is a centurial year (ending in 00).
3. Then it is not a leap year,
4. unless it is a year divisible by 400, in which case it is still
a leap year.
For example:
1904 is a leap year—evenly divisible by 4.
1900 is not a leap year—it is evenly divisible by 4, and also
evenly divisible by 100. However, it is not evenly divisible by
400.
2000 is a leap year— it is evenly divisible by 4, evenly divisible
by 100, but also evenly divisible by 400.
Your calculation should ignore all other variations in the length
of the calendar year, such as leap seconds or the change from the
Julian to the Gregorian system.
In: Computer Science
C++ !
Create a Stash class specifically for storing Rect objects and call it RectStash. Add a default constructor and a destructor to correctly initialize your RectStash class. Then write a program that will read several lines as input. Each line will contain 4 floats defining a 2D rectangle in the Rect format described above. Read the rectangles adding them to a RectStash object. Stop reading rectangles when your program loads 4 negative float values. After this point you will start reading a series of 2D points, and for each 2D point you will print the classification of each point in respect to all previously read rectangles. The classification should print "in" or "out" according to its result. Stop your program when you read vector (-99,-99).
Everything should be contained in one file. You may not assume the existance of any header files in your working directory.
Sample Input:
-5 -5 2.5 2.5
5 8 2 2
-1 -1 -1 -1
0 0
-4 -6
6 9
-99 -99
result:
out out
in out
out out
In: Computer Science
How to run the following code in ecclipse IDE?
MQTT PUBLISH - SUBSCRIBE MODEL CODE IN JAVA
(slide 29)public class Publisher
{
public static final String BROKER_URL =
"tcp://broker.mqttdashboard.com:1883";
private MqttClient client;
public Publisher()
{
String clientId = Utils.getMacAddress() + "-pub";
try
{
client = new MqttClient(BROKER_URL, clientId);
}
catch (MqttException e)
{
e.printStackTrace();
System.exit(1);
}
}
}
//connecting client (slide 30)
MqttConnectOptions options = new MqttConnectOptions();
options.setCleanSession(false);
options.setWill(client.getTopic("home/LWT"), //helps detecting
failures of other clients
"I'm gone".getBytes(), 2, true);
client.connect(options);
//the busniness logic (slide 31)
public static final String TOPIC_TEMPERATURE =
"home/temperature";
//...
while (true)
{
publishBrightness();
Thread.sleep(500);
publishTemperature();
Thread.sleep(500);
}
//...
private void publishTemperature() throws MqttException {
final MqttTopic temperatureTopic =
client.getTopic(TOPIC_TEMPERATURE);
final int temperatureNumber =
Utils.createRandomNumberBetween(20, 30);
final String temperature = temperatureNumber + "°C";
temperatureTopic.publish(new
MqttMessage(temperature.getBytes()));
}
//publishBrightness() will be implemented the same way publishTemperature() is
//implementing the subscribing client
public class SubscribeCallback implements MqttCallback(slide
32)
{
@Override
public void connectionLost(Throwable cause) {}
@Override
public void messageArrived(MqttTopic topic, MqttMessage
message)
{
System.out.println("Message arrived. Topic: " + topic.getName() + "
Message: " + message.toString());
if ("home/LWT".equals(topic.getName()))
{
System.err.println("Sensor gone!");
}
}
@Override
public void deliveryComplete(MqttDeliveryToken token) {}
}
\\make it known to the MqttClient before connecting (slide 34)
mqttClient.setCallback(new SubscribeCallback());
mqttClient.connect();
mqttClient.subscribe("home/#");
In: Computer Science
Write a C program which adds up all the numbers between 1 and 50. Use any type of loop
In: Computer Science
Write a JavaScript program to implement the Least-Squares Linear Regression algorithm shown below, for an arbitrary set of ( x, y ) data points entered by the user.
Least-Squares Linear Regression: • Linear regression basically means finding the ( equation for the ) straight line that is the closest “fit” to a set of ( x, y ) data points.
• Least-squares is a means of identifying the “best” fit between the line and the data. For each data point, the distance between the point and the line is calculated and squared, and the total of these squared distances is added up over all the data points. The straight line that yields the minimum value for this sum of squares is defined as the best fit.
• calculate the correlation coefficient, r, which is a metric for how well the line fits the data, and if the correlation is positive or negative. This value always lies between -1.0 and 1.0 inclusive. The closer it is to 1.0, the stronger the positive correlation; The closer to -1.0 the stronger the negative correlation; and if the coefficient is close to zero, then it shows a weak correlation ( if any ) between x and y.
The Algorithm: 1. Read in a series of ( x, y ) data pairs. While doing so, calculate the following sums:
• N = number of data pairs.
• Sx = ∑ x = Summation ( total ) of all X values.
• Sy = ∑ y = Summation ( total ) of all Y values.
• Sxx = ∑ x2 = Summation ( total ) of all X2 values.
• Syy = ∑ y2 = Summation ( total ) of all Y2 values.
• Sxy = ∑ xy = Summation ( total ) of all X∙Y values.
2. Then calculate: • Slope, m = ( N ∙ Sxy – Sx ∙ Sy ) / ( N ∙ Sxx – Sx ∙ Sx ) • Intercept, b = ( Sy – m ∙ Sx ) / N
3. Report the best-fit line as y = m x + b
4. Finally calculate and report the correlation coefficient, r, as:
• ? = ? ∙ ???−?? ∙ ?? /√( ? ∙ ???−?? ∙ ?? ) ∙ ( ? ∙ ???−?? ∙ ?? )
In: Computer Science
What's the AST(Abstract Syntax Tree) for the expression a+b*c-4 according to the following grammar, and what’s left most derivation of this expression?
expression → expression ‘+’ term | expression ‘-’ term | term
term → term ‘*’ factor | term ‘/’ factor | factor
factor → identifier | constant | ‘(‘ expression ‘)’
In: Computer Science
Solve Quadratic Equation IN JAVA (static methods, parameters, arguments, Math functions)
Write a program that will print the real-valued solutions of a quadratic equation
ax^2+bx+c=0
For example:
Enter coefficient a: 1 Enter coefficient b: 10 Enter coefficient c: 2 The solutions are -0.2041684766872809, and -9.79583152331272
For another example:
Enter coefficient a: 1 Enter coefficient b: 2 Enter coefficient c: 3 The equation does not have real solution
The program should use the following methods.
b^2−4ac>=0
x = −b ± (√(b^2 − 4ac)) / (2a)
Notice that other than getCoeff() and the main() methods, methods should not interact with the user.
In: Computer Science
Write a program IN C that reads all integers that are in the range of 0 to 100, inclusive from an input file named: a.txt and counts how many occurrences of each are in the file. After all input has been processed, display all the values with the number of occurrences that were in are in the input file.
Note: The program ignores any number less than 0 or greater than 100.
Note: Do not display zero if a number is not in the file.
Hints: An array of size 101 is good enough. A number in the file plays the role of an index.
For example: Suppose the content of the file: a.txt is as
follows:
99 2 99
3
-12 80 12 33
3 99 100 1234 84
The display output is:
2 has occurred: 1 times
3 has occurred: 2 times
12 has occurred: 1 times
33 has occurred: 1 times
80 has occurred: 1 times
84 has occurred: 1 times
99 has occurred: 3 times
100 has occurred: 1 times
Note that this is just a sample dialog. Your program should work
for any number of data values and you MUST match
the sample dialog as well.
In: Computer Science
Consider the following CFG with starting variable S and Σ = {1, 2, 3, 4, 5, 6, 7,
8, 9, 0}:
S → X Y Z
X → 1 | 2
Y → W | ε
Z → Z Z | W
W → 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0
a. [20 marks] Create a derivation tree for your student number. - 84521004
b. [20 marks] Is this grammar ambiguous or unambiguous? Briefly explain (Remember the string is 84521004)
why.
In: Computer Science