Create a program that takes in a student first name and average mark obtained, the system should the group the students using the first letter in their name modulus 10 [ Remember that characters are considered as numeric values, hence ‘J’%10 is a valid calculation ]. For example if the student name is Cena, then the student belongs to group 7 because ‘C’%10 = 7 and if the name was Jack then the student belongs to group 4. The program should further use the group number to get the group lecturer and class date as follows: [Hint: If the result is 0 then the student belongs to group 10]
import java.util.Scanner;
public class App {
/**
* The start point of the program
*
* @param args
*/
public static void main(String[] args) {
Scanner keyBoard = new Scanner(System.in);
System.out.print("Enter student full names: ");
String fullName = keyBoard.nextLine();
int group = (fullName.charAt(0) % 10 == 0 ? 10 : fullName.charAt(0) % 10);
System.out.printf("Hi %s, you were placed in group %s\n", fullName, group);
if (group == 1 || group == 7 || group == 9) {
System.out.println("Group Lecturer: Mrs. T. Chikohora");
System.out.println("Group " + group + " has class on Mondays");
}
if (group == 2 || group == 4 || group == 5) {
System.out.println("Group Lecturer: Mrs. J. Muntuumo");
System.out.println("Group " + group + " has class on Wednesdays");
}
if (group == 3 || group == 6 || group == 10) {
System.out.println("Group Lecturer: Mr. S. Tjiraso");
System.out.println("Group " + group + " has class on Fridays");
}
keyBoard.close();
}
}
Comments
Leave a comment