Question
Attached are 4 programs requesting specifi c types of entry requests via keyboard: Enter a specific letter Enter a specific hexadecimal number Enter a specific
Attached are 4 programs requesting specific types of entry requests via keyboard:
Enter a specific letter
Enter a specific hexadecimal number
Enter a specific string
Enter a specific integer value.
Your major objective is to modify the attached codes so that the program tests the specific entry is correct so that the code properly executes as given in output. You must use at least two tests to confirm entry is correct. You can use any function to test we have explored thus far. Use comparisons. Use relational decision making. Use length. Sorting. etc.
You may assume that the user knows the specific entry (that is they are smart) but they are contrary and like chaos; and they want to see if you can catch them in their keyboard chicanery.
Your objective is to primarily add code in the open space highlighted in Red.
Read each given code carefully. There may be some subtleties.
Your second objective is to explain your reasoning for your error checking design. For example, why did you choose a certain test versus another test? How many tests do you need to run to make sure you got the right entry? Is two enough? Can you do it one? It is expected that you will spend a time noodling over the best approaches and a little more time explaining your thoughts before you submit.
You do not have to loop or do anything extraordinary like asking for three tries. A coded response of that is an incorrect entry is an acceptable response to the improper entry or that is a correct entry to a proper entry if your reasoning is sound.
Verify a specific letter
#include
#include
#include
#include
int main()
{
char letter;
char z;
letter = z;
printf("Enter a letter : ");
scanf("%c", &letter);
Enter most of your code here.
printf("You entered: %c ", letter);
return 0;
}
Output:
Enter a letter :
z
You entered: z
Verify a specific hexadecimal value
#include
#include
#include
#include
int main()
{
int hex = 0xFAFA12C;
printf("Enter the hexadecimal number : ");
scanf("%X", &hex);
Enter most of your code here.
printf("You entered: %X ", hex);
return 0;
}
Output:
Enter the hexadecimal number :
0xFAFA12C
You entered: FAFA12C
Verify a specific string
#include
#include
#include
#include
int main()
{
char str[50];//12mnoBBZXY7700
printf("Enter a string : ");
scanf("%s", &str);
Enter most of your code here.
printf("You entered: %s ", str);
return 0;
}
Output:
Enter a string :
12mnoBBZXY7700
You entered: 12mnoBBZXY7700
Verify a specific integer number
#include
#include
#include
#include
int main()
{
int grade = 100;
printf("Enter a specific numeric grade you will get in this class : ");
scanf("%d", &grade);
Enter most of your code here.
printf("You entered the grade: %d ", grade);
return 0;
}
Enter a specific numeric grade you will get in this class :
100
You entered this grade: 100
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started