|Better (lab 1) but I get this because you used atoi instead of atof (-2):|
Enter the temperature outside right now (degrees F): 45.67
It's 45 degrees in...
Think about what you should have done in your testing before submitting this, because you should have found this logic error before I did. Make sure you know all the requirements for lab 1, and fix and resubmit it.
|What is his problem?|
|LAB 1: Console Programming Basics [ TheBasics.cpp ] |
Following the programming conventions for this course, write a C++ console program named TheBasics.cpp, to read and print two sets of inputs, with two calculated values. Be sure to do things in the order specified.
The first set is the user's age (in whole number years) and name (first and last), in that order, each on its own separate line, following its prompt. The second set is the current outside temperature (in floating point degrees F), and the user's location (city), in that order, each on its own separate line, following its prompt. For example:
Enter your age: 21
Enter your name: Joe Student
Enter the temperature outside right now (degrees F): 45
What city are you in right now? Walnut Creek
After both sets have been read in, calculate two values: (1) the user's age one year from now, and (2) the temperature in degrees C. Finally, print the 4 input values and the two calculated values in the following 2-line format, spaced and punctuated per the example:
Joe Student is 21 years old now, and will be 22 a year from now.
It's 45 degrees F in Walnut Creek -- that's 7.2 degrees C.
Here are the specifications, in addition to the universal requirements and programming conventions explained in lab 1b above:
If the user enters a non-numeric for age or temperature, the program should not fail -- non-numeric entries should default to zero.
Print the degrees F in the same precision as entered (that is, if the input is 45.61, print it as 45.61).
Print the degrees C with one digit after the decimal point, rounded to the closest tenth of a degree.
Do NOT use the manipulator "fixed".
Use ONLY int and double for numeric variables.
For text variables, use C strings, or C++ strings, or both, as you prefer.
Be sure to include your identifying information in both comment form and cout form.
Refer to your notes from lecture, that should explain how to do these.
HINTS: If you have to use if-statements in this one, you are not doing it right. Also, the "fixed" in cout << fixed; IS a manipulator -- do NOT use it. The use of "fixed" in cout.setf(ios::fixed|ios::showpoint); is NOT a manipulator -- you may use it.