Does it mean the program doesn\'t show any errors? Anyone care to explain? Here\
ID: 3649787 • Letter: D
Question
Does it mean the program doesn't show any errors? Anyone care to explain? Here's the context:"For each, answer this: does the program accept the input or not? Also, if the program does not terminate with a fatal error, what does the output show?
When prompted to enter your age, which is to be stored as an integer, what happens if you enter (a) a value with a decimal, such as 21.5, or (b) a text value, such as twenty-one?
When prompted to enter your GPA, which is to be stored as a floating point number, what happens if you enter (a) a value without a decimal, such as 4, or (b) a text value, such as four?
When prompted to enter your name, which is to be stored as any-character text, what happens if you enter (a) a decimal value, such as 3.14, or (b) a text value, such as George Washington?
When prompted to enter your gender, which is to be stored as single-character text, what happens if you enter (a) a whole number, such as 4, or (b) a decimal value, such as 3.14, or (c) a text value, such as male?"
Explanation / Answer
1. When prompted to enter your age, which is to be stored as an integer, what happens if you enter (a) a value with a decimal, such as 21.5, or (b) a text value, such as twenty-one? A) entering the decimal 21.5, the program truncates it to just the integer part (21). B) entering a text value ("five") causes the program to terminate unexpectedly. 2. When prompted to enter your GPA, which is to be stored as a floating point number, what happens if you enter (a) a value without a decimal, such as 4, or (b) a text value, such as four? A) entering a whole number, the program will still store it as a floating ponit number, and when it is displayed with setprecision(2), there will be 2 decimal points. B) entering a text value like "four" causes the program to terminate unexpectedly. 3. When prompted to enter your name, which is to be stored as any-character text, what happens if you enter (a) a decimal value, such as 3.14, or (b) a text value, such as George Washington? A) when entering a decimal value for Name, the program still interprets it as a string because 'name' is a string variable. B) entering a text value such as "George Washington" works fine because the program is storing it in a string variable. 4. When prompted to enter your gender, which is to be stored as single-character text, what happens if you enter (a) a whole number, such as 4, or (b) a decimal value, such as 3.14, or (c) a text value, such as male? A) single digit whole number - that single character is stored whole number (more than one digit) - the first digit is stored as a single char B) decimal - anything after the first digit is truncated (only the first digit is stored, as a single char) C) text value - only the first letter of the string is stored
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.