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...
Trending nowThis is a popular solution!
Chapter 8 Solutions
MindTapV2.0 for Farrell's Java Programming with 2021 Updates, 9th Edition [Instant Access], 1 term
- 3. 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.arrow_forwardWrite 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.arrow_forwardIn javas coding please Write a program that opens the salesdat.txt file and processes it contents. The program should display the following per store: The total sales for each week. (Should print 5 values - one for each week). The average daily sales for each week. (Should print 5 values - one for each week). The total sales for all the weeks. (Should print 1 value) The average weekly sales. (Should print 1 value) The week with the highest amount in sales. (Should print 1 week #) The week with the lowest amount in sales. (Should print 1 week #) All Values (Total Sales, Average Daily Sales for Each Week, Total Sales for all Weeks, Average Weekly Sales, Highest Amount in Sales, Lowest Amount in Sales) The file contains the dollars amount of sales that a retail store made each day for a number of weeks. Each line in the file contains thirty five numbers, which are sales numbers for five weeks. The number are separated by space. Each line in the file represents a separate store.…arrow_forward
- Write an application that displays the factorial for every integer value from 1 to 10. A factorial of a number is the product of that number multiplied by each positive -integer lower than it. For example, 4 factorial is 4 * 3 * 2 * 1, or 24. Save the file as Factorials.cpp.arrow_forwardPlease provide answer in C#: Slot Machine Simulation A slot machine is a gambling device into which the user inserts money and then pulls a lever (or presses a button). The slot machine then displays a set of random images. If two or more of the images match, the user wins an amount of money that the slot machine dispenses back to the user. Create an application that simulates a slot machine. Figure 8-23 (on page 539 of your book) shows an example of how the form should look. The application should let the user enter into a TextBox the amount of money he or she is inserting into the machine. When the user clicks the Spin button, the application should display three randomly selected symbols. (Slot machines traditionally display fruit symbols. You will find a set of fruit symbols attached to this dropbox for your use - from the Student Sample Programs provided by the book author.) If none of the randomly displayed images match, the program should inform the user that he or she has won…arrow_forwardUsing C# in Microsoft Visual Studio 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…arrow_forward
- 2. The Integer.parseInt () method requires a String argument, but fails if the String cannot be converted to an integer. Write an application in which you try to parse a String that does not represent an integer value. Catch the Number FormatException that is thrown, and then display an appropriate error message. Save the file as Try ToParseString.java.arrow_forwardWrite 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.The code must be visible!!!arrow_forwardWrite an application for Cody’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 $25, $22, $15, or $5, accordingly. Display Invalid Entry if the user enters an invalid item. An example of the program is shown below: Enter selection: oil change tire rotation battery check brake inspection battery check battery check price is $15arrow_forward
- 1# Write a program that allows users to choose from one of three shapes: Squares, Circles or (right) Triangles. Allow the user to use the first letter of the shape (S, C, T) to specify what they want. After the shape is selected, ask the user for the appropriate data to calculate the shape's area, and then and print that area value to the screen for them. Area formulas you can use: Triangle: % base x height Square: length x length Circle: % Pl x radius? Notes: The floating-point data type will be your friend here. Round your area answer so that no more than 2 decimal places are shown when printing on the screen. You can use 3.1415 for Pl; Think about this as a CONSTANT in your code. For this part and especially part (b) below, think about componentizing your code. So one gigantic main() is not a best practice and not what we want to see here. Remember what we discussed about "procedural decomposition" and functions last week!arrow_forwardTravel Tickets Company sells tickets for airlines, tours, and other travel-related services. Because ticket agents frequently mistype long ticket numbers, Travel Tickets has asked you to write an application that indicates invalid ticket number entries. The class prompts a ticket agent to enter a six-digit ticket number. Ticket numbers are designed so that if you drop the last digit of the number, then divide the number by 7, the remainder of the division will be identical to the last dropped digit. Accept the ticket number from the agent and verify whether it is a valid number. Test the application with the following ticket numbers: . 123454; the comparison should evaluate to true . 147103; the comparison should evaluate to true . 154123; the comparison should evaluate to false Save the program as TicketNumber.java.arrow_forwardCreate a program that allows the user to take exam. The exam should have 10 questions (You can ask any questions). The questions are in multiple choice form and the choices are numbers. The program will display the questions one by one, and then the user can enter the correct number that corresponds to his answer. Every time the user answers question the program will check if it is correct, if the answer is correct the program will print "Correct!" otherwise it will display "Incorrect!" and the correct answer. Once the user is done with all the questions, the program will display the score and the equivalent percentage that the user got. For example: Who is the first president of the Philippines? 1. Emilio Aguinaldo 2. Joseph Estrada 3. Manuel Quezon Enter [1-4): 1 4. GMA Correct!arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT