File reading and loop. ( C++)
Create a project named Assignment 5. Save the file names-1.txt in the project. Then write a program in main.cpp, that reads the data in names-1.txt file and outputs the full name and ideal body weight for each person on the screen. Use a loop to read the names from the file. Your program should also handle an arbitrary number of entries in the file instead of handling only four entries. You apply the formula only, if the persons’ height is 5 feet or more.
Ideal Body Weight Estimation: A simple rule to estimate your ideal body weight is to allow 110 pounds for the first 5 feet of height and 5 pounds for each additional inch.
110 + ((heightInFeet - 5) * 12 + additionalInches ) * 5
For example, a person that 6 feet and 1 inches tall would be 110 + ((6-5) * 12 + 1 ) * 5
Sample run:
The ideal body weight for Tom Atto is 185 pounds.
The ideal body weight for Eaton Wright is 135 pounds.
The ideal body weight for Cary Oki is 165 pounds.
I can't calculate the ideal body weight for Omar Ahmed.
File reading and loop. ( C++) Create a project named Assignment 5. Save the file names-1.txt in the project. Then write
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am