Answer to Question #231325 in Java | JSP | JSF for Momo

Question #231325
Create a class named Majors that includes an enumeration for the six majors offered by a college as follows:
ACC, CHEM, CIS, ENG, HIS, PHYS. Display the enumeration values for the user, and then prompt the
user to enter a major. Display the college division in which the major falls. ACC and CIS are in the
Business Division, CHEM and PHYS are in the Science Division, and ENG and HIS are in the Humanities
Division. Save the file as Majors.java.
1
Expert's answer
2021-08-30T18:00:14-0400
import java.util.Scanner;


class Majors {
			
		public static void main(String[] args) {
			
		String major;


		Scanner in = new Scanner(System.in);
		
		System.out.println("Enter a major: ");
	
			for (majors maj: majors.values())
			{
			System.out.println(maj);		
			}
		    major=in.nextLine();
			
			switch (major){
			case "ACC":
			case "CIS":
			System.out.println("This major falls under the Business division");
			break;
			case"CHEM":
			case"PHYS":
			System.out.println("This major falls under the Science division");
			break;
			case"ENG":
			case"HIS":
			System.out.println("This major falls under the Humanities division");
			break;
			default:
			System.out.println("This is not a major");
			}
	}
}
enum majors{ACC, CHEM, CIS, ENG, HIS, PHYS}

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