Answer to Question #255206 in Java | JSP | JSF for Monte

Question #255206

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]

Groups

Group Lecturer

Class date

1 , 7, 9

Mrs. T. Chikohora

Monday

2 , 4, 5

Mrs. J. Muntuumo

Wednesday

3, 6, 10

Mr. S. Tjiraso

Friday


1
Expert's answer
2021-10-22T16:47:21-0400

Source code

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("Enter first name: ");
        String name=in.next();
        System.out.println("Enter average mark: ");
        int average_mark=in.nextInt();
        int group=(name.charAt(0) % 10);
        if(group==0)
            group=10;
        String lecturer="";
        String date="";
        if(group==1 || group==7 || group==9){
            lecturer="Mrs. T. Chikohora";
            date="Monday";
        }
        else if(group==2 || group==4 || group==5){
            lecturer="Mrs. J. Muntuumo";
            date="Wednesday";
        }
        else if(group==3 || group==6 || group==10){
            lecturer="Mr. S. Tjiraso";
            date="Friday";
        }
        
        System.out.println("********************************************");
        System.out.println("Name: "+name);
        System.out.println("Group: "+group);
        System.out.println("Group lecturer: "+lecturer);
        System.out.println("Class date: "+date);
 }
}

Sample run 1



Sample run 2





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS