(Practice) a. Write a C++
Enter the temperature in degrees Celsius:
Have your program accept a value entered from the keyboard and convert the temperature entered to degrees Fahrenheit, using this formula:
Your program should then display the temperature in degrees Fahrenheit with an appropriate message.
b. Compile and run the program written for Exercise 2a. To verify your program, use the following test data and calculate the Fahrenheit equivalents by hand, and then use your program to see whether you get the same results:
When you’re sure your program is working correctly, use it to complete the following chart
Trending nowThis is a popular solution!
Chapter 3 Solutions
C++ for Engineers and Scientists
- -Program C 3. Negative Allergy by CodeChum Admin Whole numbers are great, but I think we should also pay attention to decimal numbers, too. So, how about we make a program that involves a lot of decimals? Instructions: Continuously ask for floating point values (decimal numbers) using the do…while() loop, sum them all up, and store the total into one variable. The loop shall only terminate for the following reasons: A negative decimal number is inputted (but still included in the total sum) The total sum reaches 100.0 or more Input 1. A series of float numbers Output The first multiple lines containing message prompts for float numbers. The last line contains the sum with 2 decimal places. Enter·a·number:·1.1 Enter·a·number:·1.2 Enter·a·number:·1.3 Enter·a·number:·1.4 Enter·a·number:·-1.0 Sum·=·4.00arrow_forward(Count positive and negative numbers and compute the average of numbers) Write a c++ program that reads an unspecified number of integers, determines how many positive and negative values have been read, and computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number. Here is a sample run:Enter an integer, the input ends if it is 0: 1 2 -1 3 0The number of positives is 3The number of negatives is 1The total is 5.0The average is 1.25arrow_forward(b) The following equations are used to calculate the voltage and power of a load in an electric circuit: Voltage of a load, V = IR Power of a load, P = 1²R (i) Draw a flowchart of a program which allows user to input the current (I) and resistance (R) of a load. The program is required to provide selections for the user to calculate either the voltage (V) or power (P) of the load. The program should also output the message "Invalid Selection" if the user makes invalid choice. (ii) Based on the flowchart above, write a complete program in C.arrow_forward
- do not submit this one) Write a C++ program that reads in a length in feet and inches and outputs the equivalent length in meters and centimeters. Use at least three functions: one for input, one or more for calculating, and one for output. Include a loop that lets the user repeat this computation for new input values until the user says he or she wants to end the program. There are 0.3048 meters in a foot, 100 centimeters in a meter, and 12 inches in a foot. (do not submit this one) Write a C++ program like that of the previous exercise that converts from meters and centimeters into feet and inches. Use functions for the subtasks. (submit this one) Write a C++ program that combines the functions in the previous two Practice Programs. The program asks the user if he or she wants to convert from feet and inches to meters and centimeters or from meters and centimeters to feet and inches. The program then inputs the values and performs the desired conversion. Have the user respond by…arrow_forward(Python) Numerous engineering and scientific applications require finding solutions to a set of equations. Ex: 8x + 7y = 38 and 3x - 5y = -1 have a solution x = 3, y = 2. Given integer coefficients of two linear equations with variables x and y, use brute force to find an integer solution for x and y in the range -10 to 10. Ex: If the input is: 8 7 38 3 -5 -1 Then the output is: x = 3 , y = 2 Use this brute force approach: For every value of x from -10 to 10 For every value of y from -10 to 10 Check if the current x and y satisfy both equations. If so, output the solution, and finish. Ex: If no solution is found, output: "There is no solution" You can assume the two equations have no more than one solution. ''' Read in first equation, ax + by = c '''a = int(input())b = int(input())c = int(input()) ''' Read in second equation, dx + ey = f '''d = int(input())e = int(input())f = int(input())arrow_forward(c) Write a C+t code to check whether a string is a valid password. Password rules: A password must have at least ten characters. A password consists of only letters and digits. A password must contain at least two digits. Expected Output: 1. A password must have at least eight characters. 2. A password consists of only letters and digits. 3. A password must contain at least two digitsarrow_forward
- (a) Produce a Pseudocode and a C++ program for a number guessing game. Your program is required to guess what a number a computer has in mind (generate number using built-in Random function) between 0 - 100. The Program prompts the user to enter a number continuously until the number match with random generated number. For each input, the program tells the users whether the input is too low or too high. So, the user can choose the next input intelligently. Sample output is as below. Guess a magic Number between 0 to 100. (Random number 8) Enter your Guess: 50 Your Guess is too High Enter your Guess: 25 Your Guess is too High Enter your Guess: 12 Your Guess is too High Enter your Guess: 6 Your Guess is too Low Enter your Guess: 9 Your Guess is too High Enter your Guess: 7 Your Guess is too Low Enter your Guess: 8 Yes, you guessed the right number 8arrow_forward(C PROGRAMMING ONLY) 7. Cornered!by CodeChum Admin Attention again soldier! Our men have been cornered by the enemy and we need to save them or else this mission will fail. The first thing we need to do is to identify them, the ones cornered by the enemy! LET'S MOVE! Instructions: Ask the user for an integer input which represents the total number of men we have in the field. Then, ask the user for the numbers of each of the men. Finally, ask the user for two numbers which represents the enemies who have cornered our men.Then, print all the numbers of our men who have been cornered by the enemy (i.e. the numbers that are in between the two numbers of the enemy).Input 1. Total number of men 2. Numbers of the men 3. First number of the enemy Constraints This is guaranteed to be lesser than the second number of the enemy 4. Second number of the enemy Output Enter·the·total·number·of·our·men:·5Men #1: 139Men #2: 100Men #3: 44Men #4: 88Men #5: 200Enemy #1: 50Enemy #2: 150 Men…arrow_forward2. (Guess the Number) Write a C program that plays the game of "guess the number" as fol- lows: Your program chooses the number to be guessed by selecting an integer at random in the range 1 to 1000. The program then types: 5.32 I have a number between 1 and 1000. Can you guess my number? Please type your first guess. The player then types a first guess. The program responds with one of the following: 1. Excellent! You guessed the number! Would you like to play again (y or n)? 2. Too low. Try again. 3. Too high. Try again. If the player's guess is incorrect, your program should loop until the player finally gets the number right. Your program should keep telling the player Too high or Too low to help the player “zero in" on the correct answer. [Note: The searching technique employed in this problem is called binary search. We'll say more about this in the next problem.]arrow_forward
- (b) Given a and b are int variables and c is a double variable. The initial value for a, b, and c are 8, 4, and 2.5. Show the working steps and result for the following expression: (i) (ii) 23 % 11 + 6.2 + a / (c + 1.5) (iii) a / static_cast(b)+ 2.0 * c a + b++ - carrow_forwardPART 2 (Lab) a. Write a C+ program that asks the user to enter N, the program should then output the Fibonacci series. Use do-while loop to ask user to re-enter N if the user entered a number below 2. Hint: The first two numbers in the Fibonacci series are 0 and 1. F, = 0 F, = 1 Any Fibonacci number is equal to the summation of the two previous numbers Fn = Fn-1+ Fn-2 Therefore, F, + F, = 1+ 0 = 1 F, + F, = 1+1= 2 F4 = F3 + F2 = 2 +1 = 3 F2 .... FN = FN-1 + FN-2 Enter N: 20 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 b. Write a program that use loops to print the following patterns separately, one below the other. In your code use for, while and do-while loops to generate the patterns, use one loop for each question. * ********* ** ******* *** ***** **** *** ***** *arrow_forward(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_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr