(Numerical analysis) a. The following is an approximate conversion formula for converting Fahrenheit to Celsius temperatures:
Using this formula, and starting with a Fahrenheit temperature of 0 degrees, write a C++
b. Using the approximate Celsius conversion formula given in Exercise 8a, write a C++ program that produces a table of Fahrenheit temperatures, exact Celsius equivalent temperatures, approximate Celsius equivalent temperatures, and the difference between the exact and approximate equivalent Celsius values. The table should begin at 0 degrees Fahrenheit, use 2-degree Fahrenheit increments, and terminate when the difference between exact and approximate values is more than 4 degrees.
Trending nowThis is a popular solution!
Chapter 5 Solutions
C++ for Engineers and Scientists
- Need a help with this programs for each of the following problem statements: - USE C++ to solve this. (Dev C++) - use of comment statements- use of descriptive variable names 1. (gcount) A program that will accept any number of grades foran exam. The grades will be input as 4 for an A, 3 for a B, 2 for a C, 1for a D, and 0 for an F. After all grades have been entered, allow theuser to enter -1 to exit. Output the number of grades in each category. - correct use of array of counters - correct use of loop - correct outputarrow_forwardPROBLEM 5 (LOOP/ITERATION) Use do while. A PRIME number is a number whose factors are one and it itself. A COMPOSITE number is a number with at least three factors, and sometimes a lot more. Make a C program that will input a number and determine if the number PRIME or COMPSITE. (10 marks) Sample output1: Sample output1: Input a number: 7 Input a number: 21 7 is NOT a PRIME number 21 is a COMPOSITE numberarrow_forward(6 marks) 3. Using functions, develop a full C++ structured program that asks the user for his choics:1 or 2. If the choice is 1, then your program will convert the entered Fahrenh (F°) temperature to Celsius (C°). If the choice is 2, then your program will convert th entered Celsius (C°) temperature to Fahrenheit (F°). use the following functions: - getTemp: read the temperature from the user - getChoice: read the user choice: 1 or 2 NOTE: only 1 or 2 are allowed, if not, then give an error message warning for three times, then exit the whole program with a message if the problem persists. - convertToF: converts Celsius to Fahrenheit Fo= (9/5) * C° + 32 - convertToC: converts Fahrenheit to Celsius C°= (5/9) * (F° - 32)arrow_forward
- (a) Write a C++ program to calculate the charges of a phone call. The call rate is as follows: Charge ($) Each minute 0.10 cent Call Duration First 10 minutes Every additional minute Each minute 0.15 cent Prompt the user to enter the call duration in floating-point format. For example, 3.2 is equivalent to 3 minutes and 2 seconds. If the input is 3.2 minutes, it is considered as 4 minutes. Display the total with two decimal places.arrow_forwardPut code as well as code with outputarrow_forwardPlease type itarrow_forward
- (C++) Question: Write a function string middle(string str)that returns a string containing the middle character in str if the length of str is odd, or the two middle characters if the length is even. For example, middle("middle") returns "dd". I'm not getting the correct output. What am I doing incorrectly?arrow_forwardPlease use C PROGRAM. Thanks in advance :)arrow_forward(Practice) Determine the value of the following expressions, assuming a=5,b=2,c=4,d=6,ande=3: a.abb.a!=bc.db==cbd.ac!=dbe.db==cef.!( ab)g.!( abc)h.!( cba)i.bcaarrow_forward
- (General math) The volume of oil stored in an underground 200-foot deep cylindrical tank is determined by measuring the distance from the top of the tank to the surface of the oil. Knowing this distance and the radius of the tank, the volume of oil in the tank can be determined by using this formula: volume=radius2(200distance) Using this information, write, compile, and run a C++ program that accepts the radius and distance measurements, calculates the volume of oil in the tank, and displays the two input values and the calculated volume. Verify the results of your program by doing a hand calculation using the following test data: radius=10feetanddistance=12feet.arrow_forward(25 min) The following table shows the foreign exchange rates for a few currencies. Foreign Currency RM USD (D) 1 Dollar 4.16 GBP (P) 1 Pound 5.68 KRW (W) 1000 Won 3.51 JPY (Y) 100 Yen 3.69 Develop a complete C++ program that will prompt the user to enter the currency preferred and the amount required. The program should include a function with the following prototype: double CurrencyBuy(char, double): The first parameter in the function prototype is for the type of currency where the characters D, P, W and Y represent Dollar, Pound, Won and Yen respectively. The second parameter is the amount to be bought. This function CurrencyBuy should return, to the calling function, the payment to be paid in RM. A sample of the output is given as follows. Foreign Exchange Currency Country Code USD (D) GВР (Р) KRW (W) JPY (Y) Enter the country code: D Enter the amount to be bought: 300 Payment due is RM 1248.arrow_forwardProblem 2. (Playing the Waltz) Write a program called playwaltz.py that accepts from standard input, a sequence of 32 integers representing the 32 measures of a waltz, and plays the waltz to standard audio. Before playing any audio, your program must check if the inputs are correct, and if they are not, must call sys.exit (message) to exit the program with an appropriate error message. The following errors must be handled: • If the number of measures is not 32, exit with the message "A waltz must contain exactly 32 measures". • If a minuet measure is not from [1,176], exit with the message "A minuet measure must be from [1, 176]". • If a trio measure is not from [1,96], exit with the message "A trio measure must be from [1, 96]". - "/vorkspace/project3 $ python3 generatewaltz.py < data/mozart.txt | python3 playwaltz. py Directions: • Read the waltz measures from standard input into a 1D list. • Handle the input errors described above. • Play each of the first 16 minuet measures by…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr