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

Question #254793

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]


1
Expert's answer
2021-10-21T12:35:19-0400
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();
		System.out.print("Enter the average mark obtained: ");
		double averageMarkObtained = keyBoard.nextDouble();
		String 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);
		
		//80 – 100 1 	Magnificent!!
		if(averageMarkObtained>=80 && averageMarkObtained<=100) {
			System.out.println("Grade Level: 1");
			System.out.println("Comment: Magnificent!!");
		}
		//70 – 79 2 Excellent!!
		else if(averageMarkObtained>=70 && averageMarkObtained<=79) {
			System.out.println("Grade Level: 2");
			System.out.println("Comment: Excellent!!");
		}
		//60 – 69 3 Good work!!
		else if(averageMarkObtained>=60 && averageMarkObtained<=69) {
			System.out.println("Grade Level: 3");
			System.out.println("Comment: Good work!!");
		}
		//50 – 59 4 Good!!
		else if(averageMarkObtained>=50 && averageMarkObtained<=59) {
			System.out.println("Grade Level: 4");
			System.out.println("Comment: Good!!");
		}
		//0 – 49 0 Fail – Try again next Year!!
		else if(averageMarkObtained>=50 && averageMarkObtained<=59) {
			System.out.println("Grade Level: 0");
			System.out.println("Comment:  Fail – Try again next Year!!");
		}
		//Greater than 100 or less than 0 X Invalid Marks!!, Marks too high. Or Invalid Marks!!, Negative marks not allowed.
		else if(averageMarkObtained>100 ) {
			System.out.println("Grade Level: X");
			System.out.println("Comment:  Invalid Marks!!, Marks too high.");
		}else {
			System.out.println("Grade Level: X");
			System.out.println("Comment: Invalid Marks!!, Negative marks not allowed.");
		}
		
		
		
		keyBoard.close();


	}


}

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