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
Mindtap Computing, 1 Term (6 Months) Printed Access Card For Farrell’s Java Programming, 8th
- . 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.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
- Please code in javas, thank you 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. Please…arrow_forwardMicrosoft Visual C# 7th edition, programming Exercise 8-2. I need help, please, thanks. Create a program for Smalltown Regional Airport Flights that accepts either an integer flight number or string airport code from the options in Figure 8-33. Pass the user’s entry to one of two overloaded GetFlightInfo() methods, and then display a returned string with all the flight details. For example, if 201 was input, the output would be: Flight #201 AUS Austin Scheduled at: 0710 (note that there should be two spaces between 'Austin' and 'Scheduled'). The method version that accepts an integer looks up the airport code, name, and time of flight; the version that accepts a string description looks up the flight number, airport name, and time. The methods return a message if the flight is not found. For example, if 100 was input, the output should be Flight #100 was not found. If no flights were scheduled for the airport code entered, for example MCO, the message displayed should be Flight to MCO…arrow_forward2. 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_forward
- 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.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_forwardWrite an application that allows a user to enter any number of student quiz scores, as integers, until the user enters 99. If the score entered is less than O or more than 10, display Score must be between 10 and O and do not use the score. After all the scores have been entered, display the number of valid scores entered, the highest score, the lowest score, and the arithmetic average. An example of the program is shown below: Enter a score >> 6 Enter another score or 99 to quit >>» 7 Enter another score or 99 to quit >» 9 Enter another score or 99 to quit >» 7 Enter another score or 99 to quit >> 99 4 valid scores were entered Highest was 9 Lowest was 6 Average was 7.25arrow_forward
- The Huntington High School basketball team has five players named Art, Bob, Cal, Dan, and Eli. Accept the number of points scored by each player in a game and create a bar chart that illustrates the points scored, similar to the chart in Figure 6-35. Save the file as BarChart.java. 13. Command Prompt C:\Java>java BarChart Enter points scored by Art >> 6 Enter points scored by Bob >> 12 Enter points scored by Cal >> 8 Enter points scored by Dan >> 2 Enter points scored by Eli >> 20 Points for Game Art Bob Cal Dan Eli ****** ******** ******** ************ ******* C:\Java>_ Figure 6-35 Typical execution of the BarChart applicationarrow_forwardA Java Practical Assignments.pdf - Adobe Acrobat Pro DC (32-bit) File Edit View E-Sign Window Help Home Tools Java Practical Assig. x Sign In 1 /1 139% Java Practical Assignments 1. Write an application that throws and catches an ArithmeticException when you attempt to take the square root of a negative value. Prompt the user for an input value and try the Math.sqrt() method on it. The application either displays the square root or catches the thrown Exception and displays an appropriate message. 2. Create a program that allows a user to input customer records (ID number, first name, last name, and balance owed) and save each record to a file. 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…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. import java.util.*; public class CarCareChoice { public static void main (String[] args) { // Write your code here } }arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage