Java Programming
Java Programming
8th Edition
ISBN: 9781305981829
Author: Joyce Farrell
Publisher: Cengage Limited
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
HistogramUse par(mfrow=c(2,2)) and output 4 plots with different argument settings.
(use R language)Scatter plot(a). Run the R code example, and look at the help file for plot() function. Try different values for arguments:type, pch, lty, lwd, col(b). Use par(mfrow=c(3,2)) and output 6 plots with different argument settings.
1. Draw flow charts for each of the following;a) A system that reads three numbers and prints the value of the largest number.b) A system reads an employee name (NAME), overtime hours worked (OVERTIME), hours absent(ABSENT) and determines the bonus payment (PAYMENT).
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,
Text book image
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage