EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
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
This is the question I am stuck on - 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. Code given -  import java.util.Scanner; import java.util.ArrayList; public class Majors {     enum Major {ACC, CHEM, CIS, ENG, HIS, PHYS};     public static void main(String[] args) {         // Write code here     } }
Create a class named CarRental that contains field's for: renter's name, zip code,size of car, daily rental fee, length of rental (in days), and total rental fee. The class should include a constructor that requires all the rental data except the daily rate and total fee, which are calculated based on the size of the car: economy size ($ 29.99 per day), midsize ($ 38.99), and full size ($ 43.50). The class also includes a display() method that will display all the rental information. Create a subclass name LuxuryCarRental. This class sets the rental fee at $79.99 per day and prompts the user to respond to the option of including a chauffeur at an addition $200 per day. Override the parent class display() method to include chauffeur fee information. Write an application named UseCarRental that prompts the user for the data needed for a rental and creates an object of the correct type. Display the total rental fee.
In main(), prompt the user for two items and create two objects of the ItemToPurchase class. Before prompting for the second item, call scnr.nextLine(); to allow the user to input a new string.Ex: Item 1 Enter the item name: Chocolate Chips Enter the item price: 3 Enter the item quantity: 1 Item 2 Enter the item name: Bottled Water Enter the item price: 1 Enter the item quantity: 10
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
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage