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_forwarduse python codearrow_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_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_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_forwardc . Write a C++ program to calculate and display the midpoint coordinates of the line connecting the two points with coordinates of (3,7) and (8,12). Use the fact that the midpoint coordinates between two points with the coordinates (x1,y1) and (x2,y2) are ((x2 + x1) / 2, (y2 + y1) / 2). Your program should produce this display:The x coordinate of the midpoint is xxx.xxThe y coordinate of the midpoint is xxx.xxThe 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.arrow_forward
- (2) The ceiling of a floating-point number x is the smallest integer that is still larger than or equal to x. Alternatively, the ceiling of a floating-point number x is what you get when you round x up to the nearest integer. For example, the ceiling of 2.1 is 3, the ceiling of 0.9 is 1, the ceiling of -4.5 is -4, etc. Write a function called ceiling (number) to compute the ceiling of a floating-point number (input argument) and returns one integer value. You may not use python's ceil() or floor() functions. Your function may use int() and/or float() functions, and your solution must use the floor division operator (i.e., '//").arrow_forwardUse C programming to solve and explain clearlyarrow_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_forward
- Problem 4. (Regular Expressions-using Python re or Java regex) Write a regular expression for the following word patterns: 1. Word starts with a 'q'. Word has 'th'. 2. 3. Word has an 'q' or a 'Q'. 4. Word starts with an 'q' or an 'Q'. 5. Word has both 'o' and 'u' in it. 6. Word does not have an 'a'arrow_forward03: 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_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr