Question #254309

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]

Expert's answer

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("Name: ");
        String name = in.nextLine();
        System.out.println("Average mark: ");
        double mark = in.nextDouble();

        System.out.println("Group: " + (name.charAt(0) % 10 == 0 ? "10" : name.charAt(0) % 10));
    }
}
LATEST TUTORIALS
APPROVED BY CLIENTS