Questions
Write a module that contains a function sqrt(y, tol=1e-6), which computes a square root of a...

Write a module that contains a function sqrt(y, tol=1e-6), which computes a square root of a number using Heron’s algorithm with guaranteed relative error less then tol. The module should run as a program that asks for user input and prints output when executed using run sqrt.py. Heron’s algorithms for finding x such that y = x^2 works as follows. First, you come up with an initial guess for x; think what it should be. Then, you update x using the following formula: xnew = 1/2 (xold + y/xold) . Computation ends once the relative deviation between x^2 and y is less then the required value.

In: Computer Science

Please read and understand the following program code. Use it to answer the following 4 questions....

  1. Please read and understand the following program code. Use it to answer the following 4 questions.

#include <iostream>

#include <string>

#include <sstream>

using namespace std;

class timeStamp // uses 24-hour times (0..24)

{

public:

    timeStamp(void);

    timeStamp(int, int, int);

    void setTime(int, int, int);

    timeStamp *addTimes(timeStamp *);

    timeStamp *subTimes(timeStamp *);

    string toString(void);

    int hour;

    int minute;

    int second;

};

int main()

{

    timeStamp noon(12, 0, 0);

    timeStamp *teaTime = new timeStamp(51, 35, 9);

    cout << "noon = " << noon.toString() << endl;

    cout << "teaTime = " << teaTime->toString() << endl;

    cout << "Time sum = "

         << (noon.addTimes(teaTime))->toString() << endl;

    cout << "Another sum = "

        << (teaTime->subTimes(&noon)).toString() << endl;

    return 0;

}

timeStamp::timeStamp(void)

{

    hour = 0;

    minute = 0;

    second = 0;

}

timeStamp::timeStamp(int h, int m, int s)

{

    hour = h;

    minute = m;

    second = s;

}

void timeStamp::setTime(int h, int m, int s)

{

    hour = s;

    minute = m;

    second = s;

}

timeStamp *timeStamp::addTimes(timeStamp *ts)

{

    int ourTime = (hour * 3600) + (minute * 60) + second;

    int theirTime = (ts->hour * 3600) + (ts->minute * 60) + ts->second;

    int timeSum = (ourTime + theirTime);

    timeStamp *newTime = new timeStamp();

    newTime->hour = timeSum / 3600;

    newTime->minute = (timeSum % 3600) / 60;

    newTime->second = ((timeSum % 3600) % 60);

    return newTime;

}

timeStamp *timeStamp::subTimes(timeStamp *ts)

{

    int ourTime = (hour * 3600) + (minute * 60) + second;

    int theirTime = (ts->hour * 3600) + (ts->minute * 60) + ts->second;

    int timeSum = (ourTime - theirTime);

    timeStamp *newTime = new timeStamp();

    newTime->hour = timeSum / 3600;

    newTime->minute = (timeSum % 3600) / 60;

    newTime->second = ((timeSum % 3600) % 60);

    return newTime;

}

string timeStamp::toString(void)

{

    ostringstream convert;

    convert << "hour = " << hour << ", minute = " << minute

            << ", second = " << second;

    return convert.str();

}

There are two changes needed to this program to make it compile & build correctly. Please be careful and don’t go changing things all over the place.

  1. Please show the exact output from the 1stcout statement in main.

  1. Please show the exact output from the 2ndcout statement in main

  1. Please show the exact output from the 3rdcout statement in main

  1. Please show the exact output from the 4thcout statement in main

In: Computer Science

Trace Each of the following programs on the paper provided. Program 1 User enters “cat”, “dog”,...

Trace Each of the following programs on the paper provided.

Program 1

User enters “cat”, “dog”, “chair”, “quit”

  1. full = ""
  2. count = 0
  3. si = str(input("word: "))
  4. while si != "quit":
  5.     full = full + si
  6.     count = count + 1
  7.     si = str(input("word: "))
  8. print(str(count) + " words")
  9. print("Full: " + str(full));

Line Number

it doesn't have to be this specific table...

In: Computer Science

4.8 LAB: News article (CSS) Create an external stylesheet so the provided HTML produces the following...

4.8 LAB: News article (CSS)

Create an external stylesheet so the provided HTML produces the following web page:

Example rattlesnake web page screenshot

Add CSS rules to styles.css for the given news article web page that matches the following styling:

Both article's images styled with a width of 300px
Article's <h1> tag styled with:
5px padding all around
Font family of Arial
Font size of 24px
Font color of white
Background color of red
Selecting the id of author-name-and-date, style the author name and date with:
Font family of Arial
Font size of 12px
Font color of lightgray
Article's text (<p> and <ol> tags) styled with:
Font family of Times New Roman
Font size of 16px
Font color of gray
Article's share links (<a> tags) styled with:
Font family of Arial
Font size of 12px
Font color of blue
Note: Colors, font sizes, padding, etc. must be exact.


****Here is the HTML Code ****
<!DOCTYPE html>
<html>
<head>
<link href="styles.css" rel="stylesheet">
<title>5 Things to Know About Rattlesnakes and Their Babies</title>
</head>
<body>
<img src="http://www.arizona.edu/sites/default/files/UA_horiz_rgb_webheader_0.png">

<h1>5 Things to Know About Rattlesnakes and Their Babies</h1>

<p id="author-name-and-date">UA College of Pharmacy | Aug. 6, 2014</p>

<p>Arguably, snake season is year-round in Arizona, a state known for its rattlers. But baby rattlesnakes are born in July and August, making these two months especially dangerous for hikers, gardeners, children and others at high risk of exposure to rattlesnake bites.</p>

<img src="https://cdn.uanews.arizona.edu/s3fs-public/styles/2015_story_body_aspect_ratio_switcher/public/story-images/Snake%20bite%209-yr-old.jpg?OplFz4yPCASYlNqDwBjuNhjt0o6z_Djp&itok=9_xCW0fn">

<p>So far this year, 74 rattlesnake bites to humans have been reported to the Arizona Poison and Drug Information Center. Based at the University of Arizona College of Pharmacy, the center serves the entire state of Arizona with the exception of Maricopa County, providing free and confidential poison and medication information to callers around the clock.</p>

<p>Specialists answering the phones at the center regularly receive calls from Arizonans of all ages who don't realize they were bitten by a rattler. The poison center urges anyone who feels a mysterious sting, pinch or bite while outdoors to immediately call the center at 800-222-1222.</p>

<p>"We will ask a few questions that will help you either identify possible snakebite or eliminate it," said Keith Boesen, director of the Arizona Poison and Drug Information Center. "With snakebite, the sooner the medical treatment, the better the outcome, so calling us right away can make a very big difference for the victims and the medical teams treating them."</p>

<p>The center advises anyone who might come cross paths with rattlesnakes to be aware of these five things:</p>

<ol>
<li>Baby rattlesnakes range in length from 6 to 12 inches and are easily camouflaged by brush and grass.</li>
<li>Baby rattlesnakes are rattleless until they first shed their skins, so there will be no infamous "chica-chica" sound before they strike.</li>
<li>Despite their impish size, baby snakes have enough venom to be very dangerous if they bite a human.</li>
<li>Adult rattlesnakes do not always rattle an audible warning before or while they are biting.</li>
<li>It's a good idea to call the poison center if you notice an unidentified small cut or wound, even if you feel no pain. With the lack of telltale rattle warning, people can be bitten without knowing what has happened until they notice their symptoms and attribute them to a snakebite.</li>
</ol>

<p>Share: <a href="https://twitter.com/">Twitter</a> <a href="https://www.facebook.com/">Facebook</a> <a href="https://www.linkedin.com/">LinkedIn</a></p>
</body>
</html>

In: Computer Science

Finish one part before you proceed to the next part. Turn in your source code, the...

Finish one part before you proceed to the next part. Turn in your source code, the content of each file (including the text files) and the snapshot of the execution results for each part.

Part One: Write a Python program, called myEncryption.py, which takes three inputs: (1) the name of a text file, called plain.txt, (2) a user input integer k in the range of (1-25) and (3) the name of an output file, called encrypted.txt. The program encrypts the file plain.txt using the Caesar cipher algorithm and outputs one encrypted file, called encypted.txt. The plain.txt is given.

Contents of plain.txt file:

usingatexteditorsuchasnotepad
ortestedityoucancreateviewandsavedatain
atxtfilesoyoushouldmakesuretochange
thistoplaintextinyoureditorpreferencesifthatisthe
caseyour
pythonprogamshoudoutputdata
toatextfileand
readcodefromit
done

Hint: The myEncryption.py program may have the following sketch of code. First, it defeins variables to take user input and open files (for read and write). Then it read the plain.txt file content line by line using the function readline(). You may need to use a while loop to control the number of loops to read the file content line by line. Your program also opens an output file for write. For each input character in a line read, it performs the encrypting operations and then writes the encrypted line characters to the output file.

           """Take user inputs.   Open files, i.e., outFile and inputFile. """

cipherCode = ""        #initialize the decrypted code

line = inputFile.readline().strip()        # read the first line from the input file

           while line!= "":           # The While loop controls to read until the end of the input file

        for ch in line:

                  """ Block of Python code to encrypt the character ch   """

                  cipherCode += chr(cipherValue) # Append the cipher character for ch to cipherCode

        outFile.write(cipherCode + "\n")

        line = inputFile.readline().strip()     # read next line from the input file

        cipherCode = ""

         """ Finally, close all the files. """

Part Two: Write a Python program, called myDecryption.py, which takes two inputs: (1) the encrypted file encrypted.txt from Part One, and (2) the same user input integer k in the range of (1-25) and decrypts the file encrypted.txt using the Caesar cipher algorithm and outputs one decrypted file, called producedPlain.txt.

Part Three: Compare the plain.txt (from Part One) and producedPlain.txt (from Part Two). Are those two text files identical? ______________________

In: Computer Science

Q.N. 1:- Given the following FM modulated signal equation, determine the frequency bandwidth. s(t)=3cos(2π13E9t + 1.04sin(2π13E3t))...

Q.N. 1:-

Given the following FM modulated signal equation, determine the frequency bandwidth. s(t)=3cos(2π13E9t + 1.04sin(2π13E3t))

a. 20kHz

b. 44kHz

c. 53 kHz

d. 106 kHz

Q.N. 2:-

Given the following message, m(t), carrier, c(t), and Kp=0.25(rad/v), determine the PM modulated signal equation and PM index. m(t)=3cos(2π3500t), c(t)=4.5cos(2π4MHzt).

a. s(t)=4.5cos(2π4E6t + 0.75cos(2π3500t)), µPM=0.75

b. s(t)=4.5cos(2π3500t + 0.75cos(2π4E6t)), µPM=0.25

c. s(t)=3cos(2π4E6t + 0.75cos(2π3500t)), µPM=0.75

d. s(t)=3cos(2π3500t + 0.75cos(2π4E6t)), µPM=0.25

old sp19

Q.N. 3:-

Given the following PM modulated signal equation, determine the original message equation, m(t). s(t)=4.4cos(2π2.4E9t + 0.99cos(2π5E3t)), Kp=0.33 (Hz/v)

a. m(t)= 4.4cos(2π5000t)

b. m(t)= 4.4cos(2π2.4E9t)

c. m(t)= 3cos(2π5000t)

d. m(t)= 3cos(2π2.4E9t)

Q.N. 4:-

Given the following PM modulated signal equation, determine the frequency bandwidth. s(t)=3cos(2π13E9t + 2cos(2π13E3t))

a. 22kHz

b. 40kHz

c. 78 kHz

d. 116 kHz

In: Computer Science

You need to design a Web Server, Database Server and a Backup server. If you had...

You need to design a Web Server, Database Server and a Backup server.

If you had to choose from the following list of resources which ones would you place a priority on and state why you would do so. List these for each server type. Hint: You need to think about the functionality of the server. Based on this information, which resource would you emphasize on the most to increase the performance of the server.

  • CPU utilization and speed
  • Multiprocessing
  • Memory
  • Cache
  • Storage capacity
  • Hard drive seek and access time
  • Network Bandwidth

In: Computer Science

Decode the following secret ASCII message (reading across): 100 1000 110 0001 111 0110 110 0101...

Decode the following secret ASCII message (reading across):

100 1000 110 0001 111 0110 110 0101

010 0000 110 0001 010 0000 110 1110

110 1001 110 0011 110 0101 010 0000

110 0100 110 0001 111 1001 010 0001

Decode the following secret ASCII message (reading across):

100 1101 110 0101 110 0101 111 0100

010 0000 110 0001 111 0100 010 0000

110 1101 110 1001 110 0100 110 1110

110 1001 110 0111 110 1000 111 0100

010 1110

In: Computer Science

Project 1 - OO Programming Create a program that simulates cars racing and allows users to...

Project 1 - OO Programming

Create a program that simulates cars racing and allows users to bet on the races ( start users with $100 )

In main, prompt the user to enter details needed to create 2 instances of the Car class you create.

Ask the user to bet on which car will win the race ( use the overridden << method to display car details ), ensure the bet is between 1 and the amount of money the user has currently.

Create a Car class that has attributes for name, make, model, quarter mile time, and max speed.

( You can reference https://www.0-60specs.com/0-60-times/ - or just make values up )

Add a method Race that accepts a reference to another instance of car for the car to race.

When racing, add a random -1.0 - 1.0 second adjustment to the quarter mile time to account for wind and other conditions.

return a string result that says which car wins the race and by how much time.

Display the results of the bet and the users new balance.

Allow the user to keep creating cars to race until they are done or out of money.

In: Computer Science

Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of...

Drivers are concerned with the mileage

obtained by their automobiles. One driver has kept track of

several trips by recording miles driven and gallons used for

each trip. Develop a java program that uses a while statement

to input the miles driven and gallons used for each trip. The

program should calculate and display the miles per gallon

obtained for each trip and print the combined miles per gallon

obtained for all tankfuls up to this point.

Enter miles driven (-1 to quit): 287

Enter gallons used: 13

MPG this trip: 22.076923

Total MPG: 22.076923

Enter miles driven (-1 to quit): 200

Enter gallons used: 10

MPG this trip: 20.000000

Total MPG: 21.173913

Enter the miles driven (-1 to quit): 120

Enter gallons used: 5

MPG this trip: 24.000000

Total MPG: 21.678571

Enter the miles used (-1 to quit): -1

In: Computer Science

Overview For this program, add code to program 2 that will (potentially) allow for a discount...

Overview

For this program, add code to program 2 that will (potentially) allow for a discount to be applied to the cost of the tickets to the movie theater.

Basic Program Logic

The program should start the same as program 2 by asking the user for the number of tickets to purchase for adult and children.

The program should then ask the user if they have a discount coupon. This is a string value. A value of "Y" indicates the user does have a coupon. Any other value indicates the user does not have a coupon.

If the user does have a discount coupon, ask if the coupon is for a free adult ticket or free child ticket. This is also a string value. A value of "A" is for a free adult ticket which means that a discount of 11.25 should be applied to total purchase. A value of "C" is for a free child ticket which means that a discount of 4.50 should be applied to the total purchase. Any other value is invalid which means that no discount should be applied to the total purchase. If an invalid discount type is selected, display a message to the user that their discount type is not valid and that no discount will be applied.

Calculate the user's total purchase amount, making sure to apply the appropriate discount amount (11.25, 4.50, or 0.00).

Finally, display the results similar to program 2: the number of adult tickets that were purchased, the number of child tickets that were purchased, the discount amount (if a discount was applied to the purchase), and the total purchase amount. The discount amount should ONLY be displayed if the user indicated they had a discount coupon. As with program 2, use setw to line up the last digit of the displayed values and setprecision to display 2 digits after the decimal point.

Program Requirements

  1. At the top of the C++ source code, include a documentation box that resembles the one from programs 1 and 2.

  2. The dollar amounts should all be displayed with exactly 2 digits after the decimal point, including zeros.

  3. The numeric values read in from the user should all be integer values. The discount values read in from the user should all be string values. Use meaningful variable names.

  4. Make sure and test the program with values other than those in the sample output.

Output

A few runs of the program should produce the following results:

Run 1

Enter the number of adult tickets that are being purchased: 2
Enter the number of child tickets that are being purchased: 5

Do you have a discount coupon (Y for yes)? Y

Is the discount for an adult or child's ticket (A for adult, C for child)? C


************************************
           Theater Sale
************************************
Number of adult tickets:           2
Number of child tickets:           5

Discount:                       4.50

Total purchase:                40.50

Run 2

Enter the number of adult tickets that are being purchased: 1
Enter the number of child tickets that are being purchased: 2

Do you have a discount coupon (Y for yes)? n


************************************
           Theater Sale
************************************
Number of adult tickets:           1
Number of child tickets:           2

Total purchase:                20.25

Run 3

Enter the number of adult tickets that are being purchased: 2
Enter the number of child tickets that are being purchased: 2

Do you have a discount coupon (Y for yes)? Y

Is the discount for an adult or child's ticket (A for adult, C for child)? S
Error: S is not a valid discount type. No discount will be applied

************************************
           Theater Sale
************************************
Number of adult tickets:           2
Number of child tickets:           2

Discount:                       0.00

Total purchase:                31.50

Run 4

Enter the number of adult tickets that are being purchased: 4
Enter the number of child tickets that are being purchased: 2

Do you have a discount coupon (Y for yes)? Y

Is the discount for an adult or child's ticket (A for adult, C for child)? A


************************************
           Theater Sale
************************************
Number of adult tickets:           4
Number of child tickets:           2

Discount:                      11.25

Total purchase:                42.75

In: Computer Science

Q.N. 1:- An AM index between 0 and 1 indicates what? a. the AM signal is...

Q.N. 1:-

An AM index between 0 and 1 indicates what?

a. the AM signal is very small and will not be detected by the receiver

b. distortion of the signal will prevent detection and demodulation

c. the received modulated signal will have minimal distortion

d. the AM index is not important

Q.N. 2:-

Given the following AM modulated signal, determine the original message, m(t):

s(t) = 2.5[1+0.5 cos(2π25kHzt)] cos(2π88MHzt)

a. m(t) = 1.25cos(2π25kHz*t)

b. m(t) = 1.25cos(2π88MHz*t)

c. m(t) = 2.5cos(2π25kHz*t)

d. m(t) = 2.5cos(2π88MHz*t)

Q.N. 3:-

Given the following AM modulated signal, determine the occupied frequency bandwidth(note: assume double-sideband large carrier (DSB-LC):

s(t) = 2.4[1+0.7 cos(2π33Hz*t)] cos(2π10GHz*t)

a. Frequency bandwidth = 33 Hz

b. Frequency bandwidth = 66 Hz

c. Frequency bandwidth = 10GHz

d. Frequency bandwidth = 20GHz

Q.N. 4:-

Given the following message and carrier equations, determine the AM modulated signal equation: m(t)=4cos(2π4kHz*t), c(t)=4cos(2π3GHz*t)

a. s(t)=2[1 + 0.67cos(2π4000t)]cos(2π3GHz*t)

b. s(t)=2[1 + 0.67cos(2π3E9t)]cos(2π4kHz*t)

c. s(t)=4[1 + 1cos(2π4000t)]cos(2π3E9t)

d. s(t)=4[1 + 1.5cos(2π3GHz*t)]cos(2π4000t)

In: Computer Science

Design and implement a class called circle_location to keep track of the position of a single...

Design and implement a class called circle_location to keep track of the position of a single point that travels around a circle. An object of this class records the position of the point as an angle, measured in a clockwise direction from the top of the circle. Include these public member functions:
• A default constructor to place the point at the top of the circle.
• Another constructor to place the point at a specified position.
• A function to move the point a specified number of degrees around the circle. Use a positive argument to move clockwise, and a negative argument to move counterclockwise.
• A function to return the current position of the point, in degrees, measured clockwise from the top of the circle. Your solution should include a separate header file, implementation file,
and an example of a main program using the new class.

In: Computer Science

Write a program in C that takes as input a four-digit hexadecimal number and prints the...

Write a program in C that takes as input a four-digit hexadecimal number and prints the next

10 hexadecimal numbers. Define a hexadecimal number as

int hexNum[4]

Allow upper- or lowercase letters for input and use uppercase letters for the hexadecimal

output. For example, 3C6f should be valid input and should produce output 3C6F, 3C70,

3C71, . . . .

In: Computer Science

Write a program in C that takes as input an 8-bit binary number and prints the...

Write a program in C that takes as input an 8-bit binary number and prints the next 10 binary

numbers. Define a binary number as

int binNum[8];

Use binNum[0] to store the most significant (i.e., leftmost) bit and binNum[7] to store the least

significant bit. Ask the user to input the first binary number with each bit separated by at

least one space.

In: Computer Science