In: Computer Science
Write a python code that uses the Euler Implicit method to approximate/plot the solutions to each of the following initial-value
In: Computer Science
7. Amdahl’s law provides a very useful metric to measure speedup when we make applications parallel using more resources. However, Amdahl’s law’s basic form makes an assumption about the application that may not hold in real-world scenarios. State the assumption made by Amdahl’s law and describe conditions that may break the assumption.
In: Computer Science
Write a member method named countMin. This method is inside the class SingleLinkedList<E>. So it has the direct access to Node<E> class and data fields head, size. This method counts how many times the smallest data item in this SingleLinkedList<E> appears in the list. It is assumed that the class passed to E implements the Comparable<E> interface.
public int countMin()
----------------------
Write a method named endWith. This method is OUTSIDE the class LinkedList<E>. It takes in two parameters: two LinkedList of Integers named list1, list2. It checks if list1 ends with list2, and returns true if yes, false otherwise. list1 ends with list2 if list2 is identical to the tail of list1. For example, list1 below ends with list2 below.
list1: 100 80 200 250 30 20 35
list2: 30 20 35
public static boolean endWith(LinkedList<Integer> list1, LinkedList<Integer> list2)
----------------
Write a method named changeStack that takes in a Stack of Integer objects named stackIn as a parameter and returns another Stack of Integer objects. The returned Stack contains contents that is the result of switching the top half and the bottom half of the stackIn. But the ordering of integers in each half is NOT changed. In the case of odd-size stackIn, the middle element remains in the same position before and after the switch.
This method is OUTSIDE the class <E>.
Example 1:
stackIn Returned Stack
top top
30 100
10 50
100 30
bottom 50 10 bottom
Example 2:
stackIn Returned Stack
top top
15 65
3 8
200 200
65 15
bottom 8 3 bottom
The Stack class includes all methods necessary for the stack operations. You can consider Stack is like the ArrayDeque in Java API used as a Stack.
public static Stack<Integer> changeStack(Stack<Integer> stackIn)
In: Computer Science
Can someone take a look and tell me what I have wrong here. VS 2019 .net framework console app c##
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace dropbox10
{
class MainClass
{
public static void Main(string[] args)
{
//create a list of employees
List<Employee> allEmployees = new List<Employee>();
//create two full time employees
FullTimeEmployee fe1 = new FullTimeEmployee("111", "Alice",
67888.00m);
FullTimeEmployee fe2 = new FullTimeEmployee("222", "Bob",
67555.00m);
//create two part time employees
PartTimeEmployee pe1 = new PartTimeEmployee("333", "Chuck", 22.12m,
20m);
PartTimeEmployee pe2 = new PartTimeEmployee("444", "Dan", 23.33m,
18.45m);
//add employees to list
allEmployees.Add(fe1);
allEmployees.Add(fe2);
allEmployees.Add(pe1);
allEmployees.Add(pe2);
//display data
foreach (Employee emp in allEmployees)
{
Console.WriteLine(emp);
}
Console.ReadKey();
}
}
}
//the required employee class
class Employee
{
//fields
private string employeeId;
private string employeeName;
//properties
public string EmployeeId
{
get { return employeeId; }
set { employeeId = value; }
}
public string EmployeeName
{
get { return employeeName; }
set { employeeName = value; }
}
public Employee(string employeeId, string employeeName)
{
this.employeeId = employeeId;
this.employeeName = employeeName;
}
//required toString method
public override string ToString()
{
string str;
str = string.Format("ID: {0} Name: {1}", EmployeeId,
EmployeeName);
return str;
}
}
//the required class
class FullTimeEmployee : Employee
{
//field
private decimal annualSalary;
//property
public decimal AnnualSalary
{
get { return annualSalary; }
set { annualSalary = value; }
}
//consturtor
public FullTimeEmployee(string employeeId, string employeeName,
decimal annualSalary)
: base(employeeId, employeeName)
{
this.annualSalary = annualSalary;
}
//GetweeklyPaid() method
public decimal GetWeeklyPaid()
{
decimal payAmount;
payAmount = AnnualSalary / 52;
return payAmount;
}
//ToString() method
public override string ToString()
{
string str;
str = base.ToString() + string.Format(" Pay amount: {0:C}",
GetWeeklyPaid());
return str;
}
class PartTimeEmployee : Employee
{
//fields
private decimal hourlyWage;
private decimal hoursWorked;
//properties
public decimal HourlyWage
{
get { return hourlyWage; }
set { hourlyWage = value; }
}
public decimal HoursWorked
{
get { return hoursWorked; }
set { hoursWorked = value; }
}
//constuctor
public PartTimeEmployee(string employeeId, string
employeeName,
decimal hourlyWage, decimal hoursWorke)
: base(employeeId, employeeName)
{
this.hourlyWage = hourlyWage;
this.hoursWorked = hoursWorked;
}
//GetWeeklyPaid() method
public decimal GetWeeklyPaid()
{
decimal payAmount;
payAmount = HoursWorked * HourlyWage;
return payAmount;
}
//ToString() method
public override string ToString()
{
string str;
str = base.ToString() + string.Format(" Pay amount: {0:C}",
GetWeeklyPaid());
return str;
}
}
}
In: Computer Science
Introduction: Programmers for a Better Tomorrow
Programmers for a Better Tomorrow is an organization dedicated to helping charities, medical societies, and scholarship organizations manage various tasks so that they can focus on making the world a better place! They have asked you and your classmates to help them develop some new programs to benefit their organizations.
After nearly a semester of C programming, you've decided that you'd like to donate your skills to create a program that organizes the typical activities for charity run weekend. In particular, your program will help manage the following:
1) Individual Registration
2) Team Registration
3) Running Events
4) Donation Totals
Your program will log the number of teams and individual who are signed up for the different races, process the racing events to see who has the fastest times, and track the total amount of money raised by teams and individuals for charity.
Header Specification
To facilitate grading, include in your header comment which portions of the assignment you have completed. You must complete all portions in order to earn full credit, but partial credit is available for completing some of the steps. The primary steps are as follows:
(1) Processing Individual Registrations
(2) Processing Team Registrations
(3) Processing the running events
(4) Calculating total donations
If your comment is accurate, meaning that you pass the appropriate tests cases corresponding to your choice, you'll earn 10 points. If your comment is roughly accurate, meaning that you sincerely attempted the items you listed, and most of them work minus a tiny bug, then you'll get 5 of these points. If your comment isn't accurate to a reasonable degree, you'll get 0 of these points.
The reason this is here is because it's very important to communicate to others accurately what you've accomplished and what is left to accomplish. This sort of honesty and ability to appraise your own work is a critical skill in a job.
Program Details
Individual Registration Details
There are a two registration windows: early registration and regular registration. Prices for registering early and regularly will be given. Each individual will have a unique number and must be processed separately to record their name, age, running event, and donations raised. The maximum number of runners for our program will be 10000.
Team Registration Details
Teams may be created and registered to sign up several participators at once. Teams may only sign up during early registration, have between 3 and 50 members, and must pay the team registration fee for every member on the team. Teams should be recorded with their name and number of members. Each member of the team still needs to be recorded with their name, age, running event, and donations raised. We can organize at most 200 teams.
Running Events Details
There will be three running events: a 5k race, a 10k race, and a marathon race. For each race, your program will receive the running time for each participant in the race. For the 5k and the 10k you should print the runner with the fastest time. For the marathon, your program will need to check times against the required qualifying times to see which runners qualify for more marathon races. These qualifying times vary by age group.
Total Donation Details
After all the races are run we want to recognize the participants who raised the most money for charity. Print the team that raised the most money for the event along with the amount raised. Then for each team, print the team member who raised the most money along with the amount raised. For the individuals, print the top individual who raised the most money along with the amount raised. Finally, print the total amount raised for the event. All donations and registration fees will be donated directly to charity.
Implementation Restrictions
You must use the following constants:
#define TEAMS 200
#define RUNNERS 10000
#define LENGTH 20
#define TEAMSIZE 50
You must use the following structures to store information:
struct person {
char name[LENGTH];
int number;
int age;
int event;
float money;
float time;
};
struct team {
char name[LENGTH];
int nummembers;
float money;
struct person members[TEAMSIZE];
};
It is not sufficient to simply have the structures in your program, you must use them store information and process operations for the program.
Though function prototypes will not be provided, it is expected that you follow good programming design and create several functions with well-specified tasks related to the solution of this problem. Make sure to pay very careful attention to parameter passing.
Input Specification
The first line of the file contains the following three values, separated by spaces:
Cost of early registration for individuals (in dollars), Cost of regular registration for individuals (in dollars), and the cost of team registration (in dollars). These will be positive real numbers to two decimal places.
The second line of the file will contain one positive integer representing the number of early individuals and teams who are registering. Every registration will start with either TEAM or INDV for a team registration or individual registration respectively.
Lines that begin with INDV will be followed by four values, separated by spaces:
The individual’s name, their age, their chosen running event, and the amount of donations they have raised. The first is a string, the second is a positive integer, the third is an integer from the set {5, 10, 42}, and the fourth is a positive real number.
Lines that begin with TEAM will be followed by two values, separated by spaces: the name of the team and the number of team members (k). This will be followed by k lines organized the same as the individual registration above.
After early registration completes, normal registration can begin. This will be represented by one positive integer (m) representing the number of regular registrations. All teams must use early registration. This will be followed by m lines each with four values. These are the same values that are present in individual registration: The team member’s name, their age, their chosen running event, and the amount of donations they have raised. The first is a string, the second is a positive integer, the third is an integer from the set {5, 10, 42}, and the fourth is a positive real number.
After registration, the running events can occur. Every registered participant will be listed with their number (assigned as part of registration) and the time it took them to run the race in minutes represented as a real number.
This will be followed by 10 lines of qualifying times based on age groups. They will be specified:
STARTINGAGE ENDINGAGE TIME
where starting age and ending age are integers, and the qualifying time is a real number representing minutes.
Output Specification
For an individual registering for an event print a line of the form:
X registered for the Y race! They have been assigned the number Z.
where X is their name and Y is the event they are registering for. Y is represented by an integer {5, 10, 42} in the input file. Replace it with “5k” for the first integer, “10k” for the second integer, and “marathon” for the third integer in this print statement. Z is their unique runner number. These numbers should start at 1 and count up to a max of 10000.
For a team registering print a line with one of the form:
X team registered for the event. They have Y members:
where X is the team name and Y is their number of members. Follow this with Y lines of the same form as the individuals: one for each member of the team.
For the 5k race and the 10k race, output a single line of the following form:
Xk race: Y had the fastest time with Z.Z minutes!
where X is either 5 or 10 respectively, Y represents the name of the fastest runner and Z represents their time.
For the marathon race, print out all the runners who times meet the qualifying times:
X qualified in the marathon run with a time of Y.Y minutes!
where X represents the name of the fastest runner and Y represents their time.
For the team that raised the most money, output a single line of the following form:
The X team raised the most money with a team donation of $Y.YY!
where X is the team name and Y is the amount they raised.
For each team, print out the person that raised the most with a single line of the following form:
X raised the most money on team Y with a donation of $Z.ZZ!
where X is the person’s name, Y is the team name, and Z is the amount they raised.
For the individual that raised the most money, output a single line of the following form:
X raised $Y.YY!
where X is the person’s name and Y is the amount they raised.
End with the total amount raised by the event:
The runners raised $X.XX for charity!
Sample Input/Output
Four sets of input and output are provided with the assignment, showing the different portions of the assignment. You should try to complete race01 first, then proceed to race02, and so forth.
race01.txt
25.5 35.75 21
5
INDV Emily 30 5 10
INDV Karla 27 10 25.6
INDV Martin 45 5 33.75
INDV Lucas 23 42 100
INDV Hayley 34 42 27.43
7
George 50 10 90.3
Evelyn 47 5 15.4
Linus 55 10 22.8
Charlie 40 42 150.75
Lucy 24 10 14.89
Leah 42 5 23.45
Thomas 29 5 10.6
race02.txt
25.5 35.75 21
7
INDV Emily 30 5 10
INDV Karla 27 10 25.6
INDV Martin 45 5 33.75
TEAM OATS 5
Maria 22 5 15.62
Caleb 41 10 20.5
Michael 30 42 18.75
Lily 33 10 31.15
Charlotte 29 5 25.8
INDV Lucas 23 42 100
INDV Hayley 34 42 27.43
TEAM RAINBOW 3
Lawrence 56 5 33.75
David 55 5 33.75
Josie 60 5 33.75
7
George 50 10 90.3
Evelyn 47 5 15.4
Linus 55 10 22.8
Charlie 40 42 150.75
Lucy 24 10 14.89
Leah 42 5 23.45
Thomas 29 5 10.6
race03.txt
25.5 35.75 21
7
INDV Emily 30 5 10
INDV Karla 27 10 25.6
INDV Martin 45 5 33.75
TEAM OATS 5
Maria 22 5 15.62
Caleb 41 10 20.5
Michael 30 42 18.75
Lily 33 10 31.15
Charlotte 29 5 25.8
INDV Lucas 23 42 100
INDV Hayley 34 42 27.43
TEAM RAINBOW 3
Lawrence 56 5 33.75
David 55 5 30.15
Josie 60 5 13.79
7
George 50 10 90.3
Evelyn 47 5 15.4
Linus 55 10 22.8
Charlie 40 42 150.75
Lucy 24 10 14.89
Leah 42 5 23.45
Thomas 29 5 10.6
1 40
2 75
3 35
4 30
5 80
6 200
7 82
8 32
9 230
10 213
11 37
12 25
13 33
14 78
15 31
16 82
17 235
18 77
19 36
20 29
18 34 215
35 39 220
40 44 225
45 49 235
50 54 240
55 59 250
60 64 265
65 69 280
70 74 295
75 79 310
race04.txt
25.5 35.75 21
7
INDV Emily 30 5 10
INDV Karla 27 10 25.6
INDV Martin 45 5 33.75
TEAM OATS 5
Maria 22 5 15.62
Caleb 41 10 20.5
Michael 30 42 18.75
Lily 33 10 31.15
Charlotte 29 5 25.8
INDV Lucas 23 42 100
INDV Hayley 34 42 27.43
TEAM RAINBOW 3
Lawrence 56 5 33.75
David 55 5 30.15
Josie 60 5 13.79
7
George 50 10 90.3
Evelyn 47 5 15.4
Linus 55 10 22.8
Charlie 40 42 150.75
Lucy 24 10 14.89
Leah 42 5 23.45
Thomas 29 5 10.6
1 40
2 75
3 35
4 30
5 80
6 200
7 82
8 32
9 230
10 213
11 37
12 25
13 33
14 78
15 31
16 82
17 235
18 77
19 36
20 29
18 34 215
35 39 220
40 44 225
45 49 235
50 54 240
55 59 250
60 64 265
65 69 280
70 74 295
75 79 310
In: Computer Science
1. Write a python code that uses the Runge Kutta Method method to approximate the solutions to each of the following initial-value problems and compare/plot the results to the actual values.
a) y′=te^(3t) − 2y, 0 < t < 1, y(0) = 0
with h = 0.5; actual solution y(t)=1/5te^(3t) − 1/25e^(3t) + 1/25e^(−2t).
- Use the Runge Kutta method to approximate/plot the solutions to each of the following initial-value
b) ?′=1+(?−?)2,2<?<3,?(2)=1y′=1+(t−y)2,2
c) ?′=1+??,1<?<1,?(1)=2y′=1+yt,1
In: Computer Science
Give the tuple calculus expressions for each using the below schema: Make a database up if needed
SPERSON(EmpID, Name, Dept)
TRIP(TripID, EmpID, ToCity, StartDate, EndDate)
EXPENSE(ExpID, TripID, AccountID, Amount)
a) List the names and employee ID of a salesperson.
b) List employee ID and employee names that took a trip(s) to New York city.
c) List the names of all employees who have spent more than $700 on their trip.
d) List employees' names and their IDs that have never taken a trip.
e) List the names of all salespersons that have at least been on one trip.
In: Computer Science
Exercise
The architectural description plays the role of the medium for
communicating design decisions among stakeholders through the
actual models of the description. The IEEE has published, a
document clarifying the recommended practice to Standardize
architectural descriptions of software systems. The standard does
not identify what views an architectural description should have,
but rather how those views should be specified. In order to create
an architectural description, you should know the following
statements: A system fulfills at least one mission and it is
influenced by its environment. Each system has an architecture.
This latter has an architectural description. An architectural
description is a set of representation models grouped into views.
Views represent certain aspects of the system, each addressing a
set of related concerns. Many stakeholders can share one concern
and each stakeholder can have many concerns. Views are specified by
viewpoints. A viewpoint identifies system stakeholders and the
concerns addressed, as well as modeling languages and modeling
techniques used to create views. The modeling languages and
modeling techniques are considered the Viewpoint Library. In the
terminology of the IEEE, a system has an architecture, which is
described by an architectural description. 1/2 An architectural
description is organized by one or more views, each of which
consists of one or more models and conforms to a viewpoint. An
architectural description selects one or more viewpoints, each of
which covers one or more stakeholder concerns. An effective
architectural description identifies a target audience (the
stakeholders) and their concerns.
Design the correspondent class diagram. [CLO
2.1]
In: Computer Science
Why a circular queue is more benefiting than a single dimension array queue? How to do indexing in a circular queue? (In java)
In: Computer Science
A. Consider the function ?(?)=?3−?−1f(x)=x3−x−1. What is the value of x after the third iteration of the Secant Method if starting guess values are 1 and 2.
Select one:
a. 1.3372
b. 1.3285
c. 1.3230
d. 1.3229
e. 0.0
B. find the value of x at the third iteration using Newton’s Method. Starting value x=1.
In: Computer Science
A palindromic number is a number that remains the same when its digits are reversed. For examples, 1, 11, 99, 121 are palindromic. Write a program that takes one array of 10 positive integers as input and output all the palindromic numbers in this array. We assume that each input number is valid, i.e., a positive integer.
Hint: You can consider the following steps to check whether a number (e.g., 121) is palindromic • Store this number to one variable, e.g., temp = 121. • Calculate the value of the number when all the digits in temp are reversed, e.g., extracting each digit in temp from the right-hand side to left-hand side, and calculating the value at the same time. • Check whether the original value equals to this calculated value.
write it in c++
In: Computer Science
data=[3831,4572,4219,2099,285,2391,3836,2290,410,4690,2031,1778,1468,4031,4513,1709,3603,4146,498,118,2635,3097,689,1340,617,394,3196,3676,4263,4110,2850,885,1926,2225,659,2643,4847,4579,977,2405,918,1256,4194,719,1218,3218,1969,395,156,3091,1860,44,2519,1763,2938,1246,1384,4034,2008,876,4346,1975,2612,2531,4518,4554,2187,3938,3396,434,4679,1681,2652,371,3884,1681,4636,3420,4880,111,566,2107,1810,4672,1716,303,1102,3777,3635,1485,2301,3127,2487,3058,1171,4240,4108,2990,334,3746,27,651,1299,1125,2475,2760,411,1932,4071,4099,4452,670,3229,2010,997,3274,2182,3072,42,4610,3657,844,1070,2697,322,4059,2255,3140,1162,1856,4111,4007,2599,4246,3508,2093,2597,1686,1014,158,1389,1032,1832,1481,2117,4947,4835,2820,2227,4469,1203,4665,3935,3946,792,1510,4940,3659,193,1603,3690,1531,761,2477,199,830,1920,1060,4717,3585,2830,3635,3205,3941,2677,3709,4544,3415,1222,3101,1010,4810,3052,3427,4702,2707,4488,458,1637,597,2105,1933,1587,231,1638,4713,1893,449,213,3822,1175,990,3349,440,2665,4248,2909,3221,1328,249,2576,4531,908,4302,728,3923,541,1330,4443,4655,2033,4761,4769,1540,48,600,2932,97,3161,2790,2093,2695,2735,3728,4879,2927,325,1244,1070,2056,2162,1367,4503,3924,3691,683,1553,716,4262,4760]
In PYTHON please write a code that implements the counting sort algorithm by making a CountingSort function with an array input. Please make the array input in the form of a list. Then sort 3 randomly generated arrays by writing code, and the data array listed below. Test all 4 arrays and print the output.
Please develop then comment on the growth function of the code, and comment on the big O notation.
In: Computer Science
Create a C++ login program using file for 2 user. Usernames must be in one file and password in the other file. Ask user for their usernames and password if it matches, they logged in successfully. If it doesn’t match,they have 3 trials ,then they have to sign in and create a username and password. After creating a username and password, they have to go to the login page again. Must work for visual studio code
In: Computer Science
It is a C++ introduction exercise and I am a rookie. Please contain detailed reasons and explanations and I would appreciate any help you can provide.
When we pass parameters to functions by value or by reference, we're doing different things; the end result will not necessarily be the same. And, of course, it's wise for us to understand exactly how the results will be different. But another angle we need to consider is why we need to have these two different kinds of parameters, which is to say that we should understand when we would be better off using one technique instead of the other.
1. What are the design benefits of passing a parameter by value? What can you do when you pass by value that you can't do when you pass by reference?
2. What are the design benefits of passing a parameter by reference? What can you do when you pass by reference that you can't do when you pass by value?
3. Suppose you were going to write a function with one parameter, and that the result would be the same whether you passed the parameter by value or by reference — it's not always the case that the outcome will be different. In what circumstances would you expect the pass-by-value version to run faster? In what circumstances would you expect the pass-by-value version to use less memory?
4. Same situation as the previous question. In what circumstances would you expect the pass-by-reference version to run faster? In what circumstances would you expect the pass-by-reference version to use less memory?
Note that these questions are not about how these techniques work, they're about why you would prefer one rather than the other.
In: Computer Science