Programming & Computer Science Answers

C++ 9913
Python 5288
Java | JSP | JSF 3611
C 1680
C# 1362
Computer Networks 989
Algorithms 652
Databases | SQL | Oracle | MS Access 641
HTML/JavaScript Web Application 588
Other 537
Visual Basic 358
Assembler 209
Software Engineering 202
AJAX | JavaScript | HTML | PHP 166
MatLAB 150
MatLAB | Mathematica | MathCAD | Maple 124
Action Script | Flash | Flex | ColdFusion 112
UNIX/Linux Programming 89
Web Development 73
Excel 36
ASP | ASP.NET 23
Delphi | Pascal 21
Perl 16
Prolog 9
Functional Programming 9
MathCAD 5
Wolfram Mathematica 4
WPF 4
Ruby | Ruby on Rails 3
NodeJS Web Application 2

Questions answered by Experts: 26 876

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Part 1


Encapsulate the following Python code from Section 7.5 in a function named my_sqrt that takes a as a parameter, chooses a starting value for x, and returns an estimate of the square root of a.


while True:

y = (x + a/x) / 2.0

if y == x:

break

x = y



Part 2


Write a function named test_sqrt that prints a table like the following using a while loop, where "diff" is the absolute value of the difference between my_sqrt(a) and math.sqrt(a).


a = 1 | my_sqrt(a) = 1 | math.sqrt(a) = 1.0 | diff = 0.0

a = 2 | my_sqrt(a) = 1.41421356237 | math.sqrt(a) = 1.41421356237 | diff = 2.22044604925e-16

a = 3 | my_sqrt(a) = 1.73205080757 | math.sqrt(a) = 1.73205080757 | diff = 0.0

a = 4 | my_sqrt(a) = 2.0 | math.sqrt(a) = 2.0 | diff = 0.0

a = 5 | my_sqrt(a) = 2.2360679775 | math.sqrt(a) = 2.2360679775 | diff = 0.0

a = 6 | my_sqrt(a) = 2.44948974278 | math.sqrt(a) = 2.44948974278 | diff = 0.0

a = 7 | my_sqrt(a) = 2.64575131106 | math.sqrt(a) = 2.64575131106 | diff = 0.0

a = 8 | my_sqrt(a) = 2.82842712475 | math.sqrt(a) = 2.82842712475 | diff = 4.4408920985e-16

a = 9 | my_sqrt(a) = 3.0 | math.sqrt(a) = 3.0 | diff = 0.0


Identify and briefly describe the following:

1 Ten application software

2 Ten input devices

3 Ten types of websites






State whether each of the following is true or false. Explain why.

a. The default case is required in the switch selection statement.

b. The break statement is required in the last case of a switch selection statement.

c. The expression ( (x > y) && (a < b ) ) is true if either x > y is true or a < b is true.

d. An expression containing the || operator is true if either or both of its operands are true.

e. The comma (,) formatting flag in a format specifier (e.g., %,20.2f) indicates that a value should be output with a thousands separator.

f. To test for a range of values in a switch statement, use a hyphen () between the start and end values of the range in a case label.

g. Listing cases consecutively with no statements between them enables the cases to perform the same set of statements.


Write a program to print the right alphabetic triangle up to the given N rows.


Create a conditional expression that evaluates to string "negative" if userVal is less than 0, and "non-negative" otherwise. Ex: If userVal is -9, output is:

-9 is negative.

In this assignment, you will use all of the graphics commands you have learned to create an animated scene. Your program should have a clear theme and tell a story. You may pick any school-appropriate theme that you like.

The program must include a minimum of:

  • 5 circles
  • 5 polygons
  • 5 line commands
  • 2 for loops
  • 1 global variable

You may wish to use the standard code for simplegui graphics below:

import simplegui

def draw_handler(canvas):

frame = simplegui.create_frame('Testing', 600, 600)
frame.set_canvas_background("Black")
frame.set_draw_handler(draw_handler)
frame.start()

Assignment is about a class which describes a jug of water. The jugs have an individual capacity (in litres) and water can be poured in and out. Water in the jug has a temperature which changes as additional water of a given temperature is poured in. For the purpose of this assignment it is assumed that the water's specific heat capacity and its density is temperature-independent. Further, it is assumed that the jug itself has negligible heat capacity and perfect insulation.

The assignment is to define a class Jug which exposes the following methods:

  • Jug creation: This takes a single parameter (aside from the standard self) which is the capacity (maximum volume of water it can accommodate) and creates an empty jug of that capacity.
  • Method pour_out(volume, into_jug=None): Water is poured out of the jug. volume is the volume in litres that is poured out. Alternatively, the string 'all' can be provided as volume, in which case the full volume of water currently in the jug is poured out. If the named parameter into_jug is assigned then the water is poured into the assigned jug. If into_jug isn't assigned, then the water is poured down the drain.
  • Method pour_in(volume, temperature): Water of the given volume and temperature is poured into the jug. Any excess water beyond the jug's capacity goes into the jug, mixes and causes water to overflow.
  • Method temperature(): Returns the temperature of the water in the jug.
  • Method water_volume(): Returns the volume of the water in the jug.
  • Method capacity(): Returns the capacity of the jug.

No other methods or attributes are exposed. Thus, if you define methods or variables to help you implement the class Jug, then their names should start with an underscore.

Assume that the water mixes and achieves a homogeneous temperature without delay. If you pour water into a jug without it overflowing, then the resulting temperature is calculated as expected from the details given at the top.

If the jug is full and added water causes it to overflow, then the temperature of water in the jug is derived as follows. When you pour water of temperature Θ

in

Θin into a full jug with water temperature Θ

Θ, as an infinitesimal volume dV

dV is added Θ

Θ changes to

Θ+dΘ=Θ∗capacity+Θ

in

∗dV

in

capacity+dV

in


.

Θ+dΘ=(Θ∗capacity+Θin∗dVin)/(capacity+dVin).

Integrating this equation will yield the final temperatureΘ(V

in

)

Θ(Vin)after a volumeV

in

Vinwith temperatureΘ

in

Θinhas been poured into a full jug, continuously mixing with the water in the jug and overflowing. Please derive Θ(V

in

)

Θ(Vin) analytically and use the resulting expression in your pour_in() method.


When writing a data structure, what should be our guidelines for choosing the right Java Collection?


a) Discuss the files systems that are supported in Windows and the devices that are supported in these

file systems.


b) Write a C/C++ system program to read text from a file in the Windows file system, and print the

text to the screen. Compile and run the program and copy the source code into your answer booklet.


c) Discuss the Windows registry and its use and interpret the following registry keys:

i. HKEY_LOCAL_MACHINE

ii. HKEY_USERS

iii. HKEY_CLASSES_ROOT

iv. HKEY_CURRENT_USER


I'm having trouble solving a c problem using graphs. I must solve it two times, one using adjacency matrix and another using adjacency list. If you guys can help me, I appreciate it! Here's the problem:

"Operating systems are large software artifacts made up of many packages.The installing of each package may require that other packages are already installed. Given a list of packages and a list of dependencies between packages,determine the number of dependents, the number of dependencies and the list of dependencies of each package."

Input:

"The first input line contains two integers separated by a blank space. The first one, N (1 ≤ N ≤ 100), is the number of packages from the operating system, which are identified by integers 1, 2,. . . , N. The second one, D (0 ≤ D ≤ 10000), is the number of dependency relations between packages. The next D lines contain the specification of the packages dependencies, each consisting of two integers ui and v , such that 1 ≤ ui, vi ≤ N, for 1 ≤ i ≤ D. The dependency specification means that installing the ui package requires prior installation of the v package. You can assume that there is no circular dependency."

Output:

"The output must consist of information about the packages and their dependencies. Each package (numbered from 1 to N) must appear immediately followed by two separate integers separeted by a space, indicating its number of dependents and dependencies, respectively. If there is at least one dependency, these two numbers must be followed by a space and then a list of the package numbers that need to be installed before it, where each package number is separated from other package numbers by a space. Do not put spaces to the right at the end of each line. There must be an exit line for each package of the operating system and, therefore, a total of N output lines."

Example(input and output lines):

4 3 (number of packages and number of dependencies) / 1 2 (package 1 depends on package 2) / 1 3 (package 1 depends on package 3) / 4 2 (package 4 depends on package 2) / 1 0 2 2 3 (information about package 1 and its dependencies) / 2 2 0 (information about package 2 and its dependencies) / 3 1 0 (information about package 3 and its dependencies) / 4 0 1 2 (information about package 4 and its dependencies)


LATEST TUTORIALS
APPROVED BY CLIENTS