Concept explainers
(Body Mass Index Calculator) We introduced the body mass index (BMI) calculator in Exercise 1.9. The formulas for calculating BMI are
Or
Create a BMI calculator application that reads the user’s weight in pounds and height in inches (or, if you prefer, the user’s weight in kilograms and height in meters), then calculates and displays the user’s body mass index. Also, the application should display the following information from the Department of Health and Human Services/National Institutes of Health so the user can evaluate his/her BMI:
BMI VALUES Underweight: less than 18.5 Normal:between 18.5 and 24.9 Overweight: between 25 and 29.9 Obese: 30 or greater |
[Note: In this chapter, you learned to use the int type to represent whole numbers. The BMIcalculations when done with int values will both produce whole-number results. In Chapter 4 you’ll learn to use the double type to represent numbers with decimal points. When the BMI calculations are performed with doubles, they’ll each produce numbers with decimal points these are called “floating-point” numbers.]
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
C++ How to Program (Early Objects Version)
Additional Engineering Textbook Solutions
Software Engineering (10th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Introduction to Programming Using Visual Basic (10th Edition)
Starting Out with Python (3rd Edition)
Big Java Late Objects
- Context: Using Python, I am also a beginner in programming. Having a hard time completing this practice and assisstance is appreciatedarrow_forward(Algebra: solve 2 x 2 linear equations) You can use Cramer's rule to solve the following 2 x 2 system of linear equation: ax + by = e ed – bf af- ec ad - bc cx + dy = f ad – bc y = Write a program that prompts the user to enter a and f and display the result. If ad - bc is 0 b, c, d , e, , report that The equation has no solution.arrow_forward(Random Walk Robot) A robot is initially located at position (0, 0) in a grid [−5, 5] × [−5, 5]. The robot can move randomly in any of the directions: up, down, left, right. The robot can only move one step at a time. For each move, print the direction of the move in and the current position of the robot. Use formatted output to print the direction (Down, Up, Left or Right) in the left. The direction takes 10 characters in total and fill in the field with empty spaces. The statement to print results in such format is given below: cout << setw(10) << left << ‘Down’ << ... ; cout << setw(10) << left << ‘Up’ << ...; If the robot moves back to the original place (0,0), print “Back to the origin!” to the console and stop the program. If it reaches the boundary of the grid, print “Hit the boundary!” to the console and stop the program. A successful run of your code may look like: Due to randomness, your results may have a different trajectory…arrow_forward
- (Random Walk Robot) A robot is initially located at position (0, 0) in a grid [−5, 5] × [−5, 5]. The robot can move randomly in any of the directions: up, down, left, right. The robot can only move one step at a time. For each move, print the direction of the move in and the current position of the robot. Use formatted output to print the direction (Down, Up, Left or Right) in the left. The direction takes 10 characters in total and fill in the field with empty spaces. The statement to print results in such format is given below: cout << setw(10) << left << ‘Down’ << ... ; cout << setw(10) << left << ‘Up’ << ...; If the robot moves back to the original place (0,0), print “Back to the origin!” to the console and stop the program. If it reaches the boundary of the grid, print “Hit the boundary!” to the console and stop the program. A successful run of your code may look like: Due to randomness, your results may have a different…arrow_forward(Computer-Assisted Instruction: Reducing Student Fatigue) One problem in CAI environments is student fatigue. This can be reduced by varying the computer’s responses to hold the student’s attention. Modify the program of Exercise 6.57 so that various comments are displayed for each answer as follows: Possible responses to a correct answer: Very good!Excellent!Nice work!Keep up the good work! Possible responses to an incorrect answer: No. Please try again.Wrong. Try once more.Don't give up!No. Keep trying.Use random-number generation to choose a number from 1 to 4 that will be used to select one of the four appropriate responses to each correct or incorrect answer. Use a switch statement to issue the responses. ------------------------------ EXERCISE 6.57 CODE: ----------------------------- //Name: IhabAtouf//Date:02/23/2023// exercise 6.57 on page 281//program description: create computer-assisted instruction (CAI) program that help students master thier math skills in…arrow_forward(Population projection) The U.S. Census Bureau projects population based on thefollowing assumptions:■■ One birth every 7 seconds■■ One death every 13 seconds■■ One new immigrant every 45 secondsWrite a program to display the population for each of the next five years. Assume thatthe current population is 312,032,486, and one year has 365 days. Hint: In Java, iftwo integers perform division, the result is an integer. The fractional part is truncated.For example, 5 / 4 is 1 (not 1.25) and 10 / 4 is 2 (not 2.5). To get an accurate resultwith the fractional part, one of the values involved in the division must be a numberwith a decimal point. For example, 5.0 / 4 is 1.25 and 10 / 4.0 is 2.5.arrow_forward
- (Demonstrate cancellation errors) A cancellation error occurs when you are manipulating a very large number with a very small number. The large number may cancel out the smaller number. For example, the result of 100000000.0 + 0.000000001 is equal to 100000000.0. To avoid cancellation errors and obtain more accurate results, carefully select the order of computation. For example, in computing the following series, you will obtain more accurate results by comput- ing from right to left rather than from left to right: 1 1 1 1+ + 3 + ... 2 п Write a program that compares the results of the summation of the preceding series, computing from left to right and from right to left with n = 50000.arrow_forward(Emirp) An emirp (prime spelled backward) is a nonpalindromic prime number whose reversal is also a prime. For example, 17 is a prime and 71 is a prime, so 17 and 71 are both emirps. Write a Java program that displays the first 100 emirps. Display 10 numbers per line with a spacing of 5; all numbers should be left-aligned.arrow_forward(Physics: acceleration) Average acceleration is defined as the change of velocity divided by the time taken to make the change, as shown in the following formula: a = (v1 - v0) / t Here, v0 is the starting velocity in meters per second, v1 is the ending velocity in meters per second, and t is the time span in seconds. Assume v0 is 5.6, v1 is 10.5, and t is 0.5, and write the code to display the average acceleration. Class Name: Exercise01_02Extraarrow_forward
- (PYTHON) The following pattern is called 5-triangle * ** *** **** ***** Create a recursive program that will print an n-triangle with the single parameter n (number of rows) that the user inputs. If the row is less than one, the method should print nothing.arrow_forwardDO NOT USE EXISTING ANSWERS ON CHEGG OR COURSE HERO OR ANY OTHER SERVICES PLEASE! Thanks :) CODE IN PYTHON AND SHOW COMMENTS TO EXPLAIN CODE A confused Dutchman trying to speak English could say “I am in the war”, even though there is no hostile activity going on. The confusion1 here is that the English sentence “I am confused” is translated in Dutch as “Ik ben in de war”, which is phonetically (“sounding”) quite close to the first sentence. Such confusion leads to much enjoyment, but can complicate matters a bit. Given a sentence in Dutch and a dictionary containing both correct translations as well as phonetic (incorrect) translations of individual words, find the translation of the sentence and indicate whether it is correct, or in case there is more than one find the total number of correct and incorrect translations. A sentence is correctly translated when each word of the sentence is correctly translated. Input The input consists of: One line with an integer n (1≤n≤20), the…arrow_forward(Algebra: solve 2 X 2 linear equations) You can use Cramer's rule to solve the following 2 x 2 system of linear equations: ed – bf af – ec y bc ax + by = e X = cx + dy = f ad ad – bc Write a function with the following header: void solveEquation(double a, double b, double c, double d, double e, double f, double& x, double& y, bool& isSolvable) If ad – bc is 0, the equation has no solution and isSolvable should be false. Write a program that prompts the user to enter a, b, c, d, e, and f and displays the result. If ad – bc is 0, report that "The equation has no solution." See Program- ming Exercise 3.3 for sample runs.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning