JAVA PROGRAM(LL)+MINDTAP (1 TERM) V2.0
JAVA PROGRAM(LL)+MINDTAP (1 TERM) V2.0
9th Edition
ISBN: 9780357616673
Author: FARRELL
Publisher: CENGAGE L
bartleby

Concept explainers

Expert Solution & Answer
Book Icon
Chapter 9, Problem 9PE

Explanation of Solution

Program:

File name: “Majors.java

//Import necessary header files

import java.util.Scanner;

import java.util.ArrayList;

//Define a class named Majors

public class Majors

{

    //Define an enumerated data type

    enum Major {ACC, CHEM, CIS, ENG, HIS, PHYS};

    //Define main method

    public static void main(String[] args)

    {

        //Declare the variables

        Major studentMajor;

        String userEntry;

        int position;

        int comparison;

        //Create an object for the Scanner class

        Scanner input = new Scanner(System.in);

        //Print the result

        System.out.println("The majors we offer are:");

        for(Major m : Major.values())

            System.out.print(m + " ");

        //Prompt the user to enter the major

        System.out.print("\n\nEnter your major >> ");

        userEntry = input.nextLine().toUpperCase();

        studentMajor = Major.valueOf(userEntry);

        //Print the result

        System.out...

Blurred answer
Students have asked these similar questions
What is cloud computing and why do we use it? Give one of your friends with your answer.
What are triggers and how do you invoke them on demand? Give one reference with your answer.
Discuss with appropriate examples the types of relationships in a database. Give one reference with your answer.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,