Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The first two functions will translate the parameter passed to it into integers

ID: 3645585 • Letter: T

Question

The first two functions will translate the parameter passed
to it into integers in the range 0-9.
- The first function will translate the letters 'A'-'J'
to the range 0-9.
- The second will translate the integer values 1-10 into
the range 0-9.

The third and fourth functions will be boolean functions
that test to see if the values passed into them are in a
specific range.
- The third function will be passed a character and will
produce true if it is in the range 'A'-'J'.
- The fourth function will be passed an integer and will
produce true if it is in the range 1-10.

Have your program read in a character and an integer.
Then print the translated results in the range of 0-9 or
print a message indicating that they are not in their
expected ranges.

Explanation / Answer

So, I'm not sure what programming language you're hoping to do this in. Here's a potential solution in Java. In Java, you can simply treat the characters as ASCII values, thus 'A' - 'A' = 0, 'B' - 'A' = 1, and so forth.

public int function1(char input) {
return input - 'A';
}

public int function2(int input) {
return input - 1;
}

public boolean function3 (char input) {
if (input >= 'A' && input <= 'J')
return true;
return false;
}

public boolean function4 (int input) {
if (input >= 1 && input <= 10)
return true;
return false;
}

Main program:
public void main(char input1, int input2) {
if (function3(input1))
System.out.println(function1(input1))
else
System.out.println("First input is not in the expected range.")

if (function4(input2))
System.out.println(function2(input2))
else
System.out.println("Second input is not in the expected range.")

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote