General math) a. Write a C++
b. How do you know the midpoint values your program calculates are correct?
c. After verifying the output your program produces, modify it to determine the midpoint coordinates of the line connecting the points (2,10) and (12,6).
d. If your program doesn’t already do so, change its output to this:
The x coordinate of the midpoint is xxx.xx
The y coordinate of the midpoint is xxx.xx
The xxx.xx denotes placing the calculated value in a field wide enough for three places to the left of the decimal point and two places to the right of it.
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
C++ for Engineers and Scientists
- (Electrical eng.) a. The voltage gain of an amplifier is given by this formula: voltagegain=[275 23 2 +0.5 f 2 ]n f is the frequency in Hz. n is the number of stages in the amplifier. Using this formula, write, compile, and run a C++ program to determine the value of the voltage gain for a four-stage amplifier operating at a frequency of 120 Hz. Your program should produce the following display: At a frequency of xxxxx hertz, the voltage gain is yyyyy Your program should replace xxxxx with the frequency and yyyyy with the voltage gain. b. Manually check the value your program produces. After verifying that your program is working correctly, modify it to determine the voltage gain of a 12-stage amplifier operating at a frequency of 9500 Hz.arrow_forwardProblem 4 - GGiven two points A(-4, –5) and B(4, 1) in XY coordinate system. 4a. Write Python code to calculate the distance between points A and B. 4b. Suppose that the line equation passing through points A and B is y = mx + b, where m is the slope and b is the y-intercept. Write the code to find the slope and the y-intercept of the line. 4c. Write a code to plot the graph of the line equation y = mx + b from part (4b) on the interval -4 < x < 4. Provide appropiate labels for both axes.arrow_forwardAbout initial programming in python: a) Given a text stored in a string, make the function that counts the number of sentences that appear in this text. Each sentence in the text is ended with a end dot (.), an exclamation point (!), a question mark (?) or ellipses (...). Exclamation or question marks no will appear repeated sequentially in the text and these symbols only appear in the text ending a sentence.In the following example, 4 sentences are told: “I need to take a nap. My God! What time is it? I'm going miss my class..." b) Make a function that, given a sentence, returns the sentence where all punctuation characters (including dashes, comma, colon, semicolon, in addition to the sentence closing punctuation) have been replaced by space. example: sentence read: "Wow, how i like chocolate." returned setence: "Wow how i like chocolate " c) Make a function that given a sentence returns another sentence that contains the same words as the sentence input in reverse order, with…arrow_forward
- Q.2. [Arithmetic Operators] Write a program to: (C++ Language) Find the product of two numbers. Convert the temperature from Farenheit to Celsius Compute and Display the average of 4 subject marks.arrow_forward• Population of a town today is 10000. The population has decreased steadily at the rate of 1% per year for last 10 years. Write a program to determine the population at the end of each year in the last decade. (Solve it with C program in Code Block). Comment/Discussion on the obtained results and discrepancies (if any).arrow_forwardPYTHON (Uee While Loop) only Write a python program that calculates the populations of foxes and rabbits who live within a certain area of land, as that number changes from year to year. It will take the initial populations as inputs, and then proceed to calculate the year-by-year changes. The following is derived from the “Lotka-Volterra equations”, which you may look up if you desire. Essentially, we will model the foxes and rabbits with 4 constants, and 2 data structures of year-by-year values. They are defined as follows: r[y] # of rabbits in year y f[y] # of foxes in year y α or alpha - birth rate of rabbits β or beta - death rate of rabbits, dependent on # of foxes γ or gamma - birth rate of foxes, dependent on # of rabbits δ or delta - death rate of foxes, caused naturally The formulas we will use are: r[y]=r[y−1]+(r[y−1]×α)−(r[y−1]×f[y−1]×β)r[y]=r[y−1]+(r[y−1]×α)−(r[y−1]×f[y−1]×β) f[y]=f[y−1]+(f[y−1]×r[y−1]×γ)−(f[y−1]×δ)f[y]=f[y−1]+(f[y−1]×r[y−1]×γ)−(f[y−1]×δ) However,…arrow_forward
- 03: Write a C++ program to obtain the value of the sine function for any angle (x) according the fallowing 02: Detect the errors (at least 8) in the following C++ program: #include int i, j. array[5 51, max!; for ( i 0, i<=5, it+) for ( j=0, j<=5, j++); 1 if (array [i,j)arrow_forward(General math) Write, compile, and run a C++ program to calculate the distance between two points with the coordinates (7, 12) and (3, 9). Use the fact that the distance between two points with the coordinates (x1, y1) and (x2, y2) is given by this formula: distance=(x2+y2) After verifying that your program works correctly by calculating the distance between the two points manually, use your program to determine the distance between the points (-12, -15) and (22, 5).arrow_forwardQ1) Write a computer program that uses Newton's method to find the root of a given function, and apply this program to find the root of the following functions, using co as given. Stop the iteration when the error as estimated by n+1 - Enl is less than 10-6. Compare to your results for bisection. (a) f(x) = 1-2xe-/2, xo = 0; (b) f(x)=5-x-¹, x = ¹; (c) f(x)= x³ - 2x - 5, xo = 2; (d) f(x)=e-2, xo = 1; (e) f(x)=x-e, xo = 1; (f) f(x)=x-x-1, xo = 1; (g) f(x)=x²-sinx, xo =/; (h) f(x)= x³-2,0 = 1; (i) f(x) = x + tan x, zo = 3; (j) f(x)=2x-¹ In x, xo = 3.arrow_forwardPnoject o. you have to create a program in C language in which the wsen enters the maas M and radius R of a circular disc and the program should display the moment of inentia of the disc about an afia perpendicular tothe plane of the rod and pass through the centen.arrow_forwardET 585 A Problem_#01] For the logic circuit shown below, develop the expression for X. 4 B A B C D Problem_#02] Write an expression for X, given the logic circuit shown below. A HOMEWORK #03 B C B Search + B Problem_#03] For the logic circuit shown below, develop the expression for X. X X Xarrow_forwardAnswer the following questions.A) the "Taylor series" stands for (MacLaurin series stands for) around the zero point of the function e^x is attached. In the form is found with the consecutive Sum expression.Accordingly, for the value x entered from the keyboard, write the flow diagram of the program that calculates e^x by opening it in a series up to the number of terms (N) entered from the keyboard. B) integers whose initial and final spelling are the same are called palindromes. Draw the program's flow diagram listing palindrome numbers from 100 to 9999.arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr