Question : implement the fundamental task of obtaining data from the person at the keyboard in order to compute a score to evaluate them for employment.
1: Prepare one separate numeric variable to hold an additional, constant piece of useful information about the user. Ensure the variable’s value, after its declaration, cannot be changed by your program’s statements.
2: Prompt the user with a printout to explain what to do, then read in one textual value from the keyboard for the name Prompt the user with a printout to explain what to do, then read in one integer numeric value from the keyboard, a value useful to evaluate the user for a job position of your choice of the person typing
3: compute a numeric value that can be used to determine whether the job application will be considered, and print out the value, including the name of the applicant, in an informative message. Use at least two different types of arithmetic
import java.util.Scanner;
public class Main {
public static final int modulo = 8;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String name;
int value;
int result = 0;
System.out.println("Please enter your name:");
name = in.nextLine();
System.out.println("What is the sum of the ASCII codes of the letters of your name modulo " + modulo + ":");
value = in.nextInt();
for (int i = 0; i < name.length(); i++) {
result += name.charAt(i);
}
System.out.println(name + ", the correct answer: " + result % modulo);
if (result % modulo == value) {
System.out.println("You are hired.");
} else {
System.out.println("You are not hired.");
}
}
}
Comments
Leave a comment