Mindtap Computing, 1 Term (6 Months) Printed Access Card For Farrell’s Java Programming, 8th
Mindtap Computing, 1 Term (6 Months) Printed Access Card For Farrell’s Java Programming, 8th
8th Edition
ISBN: 9781337091480
Author: Joyce Farrell
Publisher: Cengage Learning
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…
For this interactive assignment, you will create an application that grades the written portion of the driver’s license exam. The exam has 20 multiple-choice questions. Here are the correct answers: B  2. D    3. A     4. A     5. B      6. A      7. B       8. A      9. C     10. D      B  12. C  13. D  14. A   15. D   16. C    17. C    18. B    19. D   20. A Your program should store these correct answers in a list. The program should read the student’s answers for each of the 20 questions from a text file and store the answers in another list. (Create your own answer text file to test the application.) After the student’s answers have been read from the text file, the program should display a message indicating whether the student passed or failed the exam. (A student must correctly answer 15 of the 20 questions to pass the exam.) It should then display the total number of correctly answered questions, the total number of incorrectly answered questions, and a list showing the…
Strictly java code Write an application for Limpopo’s Car Care Shop that shows a user a list of available services: oil change, tire rotation, battery check, or brake inspection. Allow the user to enter a string that corresponds to one of the options, and display the option and its price as R250, R220, R150, or R50, accordingly. Display an error message if the user enters an invalid item.
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