C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Question
Chapter 3.4, Problem 8E
Program Plan Intro
- The variable x and y of type int are used to accept the value of x and y.
- The variable distance of type float is used to calculate shortest driving distance across the fields.
- The function sqrt is used to calculate square root of a number.
Program description:
The main purpose of the program is to accept the values of x and y and then calculate and display the shortest driving distance across the fields using given formula.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(Computer mini-project) Area of a unit circle equals rt. Cover a circle
with a 2 by 2 square and follow Algorithm 5.5 to estimate number Tt
based on 100, 1,000, and 10,000 random numbers. Compare results
with the exact value t = 3.14159265358... and comment on precision.
%3D
Please build an algorithm, test it and explain the results. Please
include code.
351 /5,000
2.
(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.]
(C prog. language)
Chapter 3 Solutions
C++ for Engineers and Scientists
Ch. 3.1 - (General math) Write an assignment statement to...Ch. 3.1 - (General math) Write an assignment statement to...Ch. 3.1 - (Conversion) Write an assignment statement to...Ch. 3.1 - Prob. 4ECh. 3.1 - (Physics) Write an assignment statement to...Ch. 3.1 - (Numerical) Write an assignment statement to...Ch. 3.1 - (Civil eng.) Write an assignment statement to...Ch. 3.1 - (Physics) Coulomb’s Law states that the force, F,...Ch. 3.1 - (Civil eng.) Write an assignment statement to...Ch. 3.1 - (Desk check) Determine the output of the following...
Ch. 3.1 - (Debug) Determine and correct the errors in the...Ch. 3.1 - Prob. 12ECh. 3.1 - Prob. 13ECh. 3.1 - (General math) The area of an ellipse (see Figure...Ch. 3.1 - Prob. 15ECh. 3.2 - Prob. 1ECh. 3.2 - Prob. 2ECh. 3.2 - (Practice) Write a C++ program that displays the...Ch. 3.2 - Prob. 4ECh. 3.2 - Prob. 5ECh. 3.2 - Prob. 6ECh. 3.2 - Prob. 7ECh. 3.2 - Prob. 8ECh. 3.2 - (Electrical eng.) The combined resistance of three...Ch. 3.2 - Prob. 10ECh. 3.2 - Prob. 11ECh. 3.2 - (Civil eng.) Write a C++ program to calculate and...Ch. 3.3 - Prob. 1ECh. 3.3 - Prob. 2ECh. 3.3 - (Practice) Write C++ statements for the following:...Ch. 3.3 - Prob. 4ECh. 3.3 - (General math) Write, compile, and run a C++...Ch. 3.3 - (General math) If a 20-foot ladder is placed on...Ch. 3.3 - (Physics) The maximum height reached by a ball...Ch. 3.3 - (Transportation) Road construction requires...Ch. 3.3 - Prob. 9ECh. 3.3 - Prob. 10ECh. 3.3 - Prob. 11ECh. 3.3 - Prob. 12ECh. 3.4 - Prob. 1ECh. 3.4 - (Practice) a. Write a C++ program that first...Ch. 3.4 - Prob. 3ECh. 3.4 - Prob. 4ECh. 3.4 - Prob. 5ECh. 3.4 - Prob. 6ECh. 3.4 - (General math) a. Write, compile, and run a C++...Ch. 3.4 - Prob. 8ECh. 3.4 - Prob. 9ECh. 3.4 - (Electrical eng.) For the series circuit shown in...Ch. 3.4 - Prob. 11ECh. 3.4 - Prob. 12ECh. 3.4 - Prob. 13ECh. 3.5 - Prob. 1ECh. 3.5 - Prob. 2ECh. 3.5 - Prob. 3ECh. 3.5 - Prob. 4ECh. 3.5 - Prob. 5ECh. 3.6 - Prob. 1ECh. 3.6 - (General math) The value of p can be approximated...Ch. 3.6 - Prob. 3ECh. 3.6 - (General math) The volume of oil stored in an...Ch. 3.6 - Prob. 5ECh. 3.6 - (General math) The perimeter, approximate surface...Ch. 3.6 - Prob. 7ECh. 3.6 - Prob. 8ECh. 3.6 - Prob. 9ECh. 3 - (General math) a. Write a C++ program to calculate...Ch. 3 - General math) a. Write a C++ program to calculate...Ch. 3 - (General math) Modify the program written for...Ch. 3 - (Biology) The number of bacteria, B, in a culture...Ch. 3 - Prob. 5PPCh. 3 - (Heat transfer) The formula developed in Exercise...Ch. 3 - Prob. 7PPCh. 3 - (Electrical eng.) a. The voltage gain of an...Ch. 3 - (Electrical eng.) a. Write, compile, and run a C++...Ch. 3 - (Electrical eng.) The amplification of electronic...Ch. 3 - (Acoustics) The loudness of a sound is measured in...Ch. 3 - (General math) a. A balance has the following...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- (C PROGRAMMING ONLY!) 3. Pet Loverby CodeChum Admin One of the easiest ways to make a pet lover happy is to give them very many pets! My friend, Jhelian is a pet lover and for her 21st birthday, I'm planning to give her very many Dogs. It's very timely because my pet dog just gave birth to a lot of cuties! So I don't really need to buy. All I need is to just give these cute little fur babies to her. Instructions: In the code editor, you are provided with the definition of a struct Dog. This struct needs a character value for its gender, which could either be 'm' for a male Dog or 'f' for a female Dog.Furthermore, an array of Dogs has already been created an each of their genders has been set. Then, on line 16, a call to the function giveDogs() was made where the dogs array was passed.Your task is to implement this giveDogs() function which has the following details:Return type - voidName - giveDogsParametersa pointer/holder of a Dogs arraysize of the Dogs arrayDescription - loops…arrow_forward(Pass or fail) Write a c++ program that prompts a student to enter a score.If the score is greater or equal to 60, display “you pass the exam”; otherwise, display “you don’t pass the exam”.Your program ends with input -1.Here is a sample run:Enter your score: 80You pass the exam.Enter your score: 59You don’t pass the exam.Enter your score: -1No numbers are entered except 0arrow_forward(permu_combi.cpp), that .arrow_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(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(Guess the Number) Write a C program that plays the game of “guess the number” as follows: Your program chooses the number to be guessed by selecting an integer at random in the range1 to 1000. The program then types:I have a number between 1 and 1000.Can you guess my number?Please type your first guess.arrow_forward
- (python) Find at least 12 issues in the code. A = int(input("Enter a number for A: ")) B = str(input("Enter a number for B: ")) C = int(input("Enter a number for C: ")) #Check that user input for A is not 0. if A = 0: print("Your coefficient for 'A' MUST BE a value greater than 0, otherwise your equation is not a quadratic!") int(input(Please enter a new value for a:")) = A import math: //Compute the discriminant. disc = (B*B) - (4*A*C) #Display the disciminant computed. print("\nThe discriminant of your equation is", str(disc) + ".") #Check the sign of the computed discriminant if disc == 0: print("This equation has 1 real solution.") x = (-B + math.sqrt(disc)) / (2 * A) print("The solution to your equation is:", x) elif disc > 0 print("This equation has 2 real solutions.") x1 == (-B + math.sqrt(disc)) / (2 * A) x2 == (-B - math.sqrt(disc)) / (2 * A) print("One solution to your equation is:", x1) print("The other solution to your equation…arrow_forward(Prism Program) Write a program that can calculate the value of the surface area and volume of a Prism. The surface area of a rectangular prism is the total area of all six faces. When you have a cube, finding the area of one face allows you to find the total surface area of the solid very quickly, since it will be six times the area of one face. A = 2(width x length) + 2(length x height) + 2(height x width) Volume is the amount of 3-dimensional space an object occupies. Volume is measured in cubic units. To find the volume of a rectangular prism, we multiply the length of the prism by the width of the prism by the height of the prism. Volume of rectangular prism = length x width x height The input and Output of your program is as follows: Prism Mania! Prism Result! Valume uf a Rectangular Prm Length 55 Width 22 Volume (Cubic CM 56550 Height 55 Surface Area (CM) 10890 Exit Calculate Do It Again Input Outputarrow_forward(Geometry: area of a regular polygon) A regular polygon is an n-sided polygon in which all sides are of the same length and all angles have the same degree (i.e., the polygon is both equilateral and equiangular). The formula for computing the area of a regular polygon is n x s? Area 4 X tan Here, s is the length of a side. Write a program that prompts the user to enter the number of sides and their length of a regular polygon and displays its area. Here is a sample run:arrow_forward
- (java programming language) Given f(x) = x+ x2/2+ x3/3+…… xn/n. Using do-while, write a program to compute f(x) for given x andn. The user should enter x and a positive integer n. Save your file as Q3.Javaarrow_forward(C++ OOP) We have a house with 3 rooms.We need the user to enter 1 integer as the window number, 2 doubles as depth and width of the room, 1 double as the useless area, 1 boolean as the door's opening direction (e.g. 0 is outward).Program will compute and print the air condition as a string and the total useful area of the house as a double. Calculating the air condition: Name it air_c. Divide the useful area by the window number. If air_c >20, output "bad". If air_c <11 output "good". If 11<=air_c<=20, output "ideal". Attention: If the window number is 0, air condition is bad. Calculating the useful area of room: Width*Depth-(useless area)if the door is inward;Width*Depth-(useless area)-0.8The worst air condition of the 3 is the final air condition of house. --- 1)The information about the home must be all private within a class.2)The class must get these inputs within constructor func.3)Calculating the useful area of a room must be done within a function of a class.4)Air…arrow_forward(C PROGRAMMING ONLY!) Your task is to fill in the blank with the correct condition. 5. Finding the Impostorby CodeChum Admin There's this Dog game I played where a group of Dogs gather together and complete missions. One of them though is an impostor because it is not a real dog; its breed is not a dog breed. Your task is to find that impostor. To do this, you need to check Instructions: In the code editor, you are provided with the enum, DogBreed. Furthermore, an initial main() code is provided for you where the user is asked for what the breed of the Dog.Then, in lines 18 - 22, a partial code to check if the breed is valid or not is given.Your task is to fill in the blank with the correct condition. Make sure to use the values of the enum, DogBreed in checking. Input 1. Dog Breed Output Input the breed of the dog: 2Yup, the breed is validarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License