Java Programming
Java Programming
9th Edition
ISBN: 9780357616635
Author: Joyce Farrell
Publisher: CENGAGE L
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 8, Problem 3PE

a.

Explanation of Solution

Program:

File name: “CarCareChoice.java

//Import necessary header files

import javax.swing.*;

//Define a class named CarCareChoice

public class CarCareChoice

{

    //Define a main method

    public static void main (String[] args)

    {

        //Declare a Boolean variable and initialize the value

        boolean isMatch = false;

        //Declare a list of available services

        String[] items =  { "oil change", "tire rotation",

         "battery check", "brake inspection"};

        //Declare an array of values

        int[] prices = {25, 22, 15, 5};

        //Declare the variables

        int x;

        int matchIndex = 0;

        //Prompt the user to enter a selection

        String menu = "Enter selection:";

        for(x = 0; x < items.length; ++x)

        menu += "\n   " + items[x];

        //Show input dialog box

        String selection = JOptionPane...

b.

Explanation of Solution

Program:

File name: “CarCareChoice2.java

//Import necessary header files

import javax.swing.*;

//Define a class named CarCareChoice2

public class CarCareChoice2

{

    //Define a main method

    public static void main (String[] args)

    {

        //Declare a Boolean variable and initialize the value

        boolean isMatch = false;

        //Declare a list of available services

        String[] items =  { "oil change", "tire rotation",

         "battery check", "brake inspection"};

        //Declare an array of values

        int[] prices = {25, 22, 15, 5};

        //Declare the variables

        int x;

        int matchIndex = 0;

        //Prompt the user to enter a selection

        String menu = "Enter selection:";

        for(x = 0; x < items.length; ++x)

            menu += "\n   " + items[x];

        //Show input dialog box

String selection = JOptionPane...

Blurred answer
Students have asked these similar questions
Create an application that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows:1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Do not display the computer’s choice yet.)2. The user selects his or her choice of rock, paper, or scissors. To get this input you can use Button controls, or clickable PictureBox controls displaying some of the artwork that you will find in the student sample files.3. The computer’s choice is displayed.4. A winner is selected according to the following rules:• If one player chooses rock and the other player chooses scissors, then rock wins. (Rock smashes scissors.)• If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors cuts paper.)• If one player chooses…
. Write an application for a college’s admissions office. Prompt the user for a student’s numeric high school grade point average (for example, 3.2) and an admission test score from 0 to 100. Display the message “Accept” if the student has any of the following:   A grade point average below 3.0 and an admission test score of at least 80 If the student does not meet either of the qualification criteria, display “Reject”. Save the file as Admission.java.
Write an application that allows a user to enter any number of student test scores until the user enters 999. If the score entered is less than 0 or more than 100, display an appropriate message and do not use the score. After all the scores have been entered, display the number of scores entered, the highest score, the lowest score, and the arithmetic average. Save the file as TestScoreStatistics.cpp.
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
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
Dictionaries - Introduction to Data Structures (Episode 8); Author: NullPointer Exception;https://www.youtube.com/watch?v=j0cPnbtp1_w;License: Standard YouTube License, CC-BY