a. Write 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 an error message if the user enters an invalid item. Save the file as CarCareChoice.java.
b. It might not be reasonable to expect users to type long entries such as "oil change" accurately. Modify the CarCareChoice class so that as long as the user enters the first three characters of a service, the choice is considered valid. Save the file as CarCareChoice2.java.
Java Programming 8th Edition
Chapter 8 Exercise 3a-b
import java.util.Scanner;
public class CarCareChoice {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Available services: oil change, tire rotation, battery check, or brake inspection");
System.out.print("Select one of the service above: ");
String service = scanner.nextLine();
if(service.equalsIgnoreCase("oil change")){
System.out.println("Price for "+service+" is $25");
}
else if(service.equalsIgnoreCase("tire rotation")){
System.out.println("Price for "+service+" is $22");
}
else if(service.equalsIgnoreCase("battery check")){
System.out.println("Price for "+service+" is $15");
}
else if(service.equalsIgnoreCase("brake inspection")){
System.out.println("Price for "+service+" is $5");
}
else{
System.out.println("Invalid service");
}
}
}
////////////////////////////////////////////////////////////////////////
import java.util.Scanner;
public class CarCareChoice2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Available services: oil change, tire rotation, battery check, or brake inspection");
System.out.print("Select one of the service above: ");
String service = scanner.nextLine();
if(service.substring(0,3).equalsIgnoreCase("oil")){
System.out.println("Price for "+service+" is $25");
}
else if(service.substring(0,3).equalsIgnoreCase("tir")){
System.out.println("Price for "+service+" is $22");
}
else if(service.substring(0,3).equalsIgnoreCase("bat")){
System.out.println("Price for "+service+" is $15");
}
else if(service.substring(0,3).equalsIgnoreCase("bra")){
System.out.println("Price for "+service+" is $5");
}
else{
System.out.println("Invalid service");
}
}
}
a. Write an application for Cody's Car Care Shop that shows a user a list of...
(A). Write an application that extends JPanel and displays a pharse in large font. Each time the user clicks a JButton, display the same pharse in a different color, a little further to the right, and in a slightly smaller font. Allow only three clicks…Save the file as JChangeSizeAndColorPanel.java (B). Modify the JChangeSizeAndColorPanel application so that it continuously changes the size, color, and location of phrase as long as the user continues to click the button. Save file as JChangeSizeAndColorPanel2.java
Write an application that calculates the amount of money earned on an investment. Prompt the user to enter an investment amount, the number of years for the investment, and the interest rate. Display an error message if the user enters 0 for any of these values; otherwise, display the total amount (balance) for each year of the investment. Save the file as Investment.java. Java Program Specific instructions: Program must use 4 methods to accomplish the following: Prompt for and return...
I) will create a rudimentary (and highly insecure) database for the storage of only the user generated identities. This program will have the following behaviors: (line break, 11 pt) ) - Prior to prompting for a new username, the existing list of usernames should be read and loaded to an array. 1 ) Read the list from "users.txt", a prompt is not necessary. Do not change this data file name "users.txt". 2 ) The existing list of usernames should be...
Create a python script to manage a user list that can be modified and saved to a text file. Input text file consisting of pairs of usernames and passwords, separated by a colon (:) without any spaces User choice: (‘n’-new user account, ‘e’-edit existing user account, ‘d’- delete existing user account, ‘l’- list user accounts, ‘q’-quit) List of user accounts, error messages when appropriate Output text file consisting of pairs of username and passwords, separated by a colon (:) without...
Write the code to maintain a list of student records. The main flow of your program should be to read all information from file(s) and place it in arrays, loop and do stuff with the records (e.g., add, update, look up, etc.), before exiting optionally write the new information back to the file(s) before exiting. Please note the files are only accessed at the beginning and the end, do not change the files during the "do stuff loop" (unless you...
FIRST: Write code that prompts the user for the name of a text file, opens that file if it exists and reads the file one line at a time printing each line to the screen. You must implement the file read in a try/catch block rather than throwing the exception on the main method. NEXT: Modify your code so that the program takes the name of two files from the command line, opens the first file if it exists for...
write a code on .C file
Problem Write a C program to implement a banking application system. The program design must use a main and the below functions only. The program should use the below three text files that contain a set of lines. Sample data of these files are provided with the assessment. Note that you cannot use the library string.h to manipulate string variables. For the file operations and manipulations, you can use only the following functions: fopen(),...
Question: Write the Main class code for the following application. The first three classes are given below. Lottery This lottery app allows users to sign up for an account, choose a random number or two, and then win a certain amount of money if their chosen number matches the number that the game draws. The house keeps the cash proceeds if nobody wins. The app must repeatedly do the following: Allow the user to (1) Add Player Account (2) Play...
Overview: You will be writing classes that implement a playlist simulation for a music streaming app.The Playlist class will contain a dynamic array of Song objects, and the Song class contains several pieces of information about a song. You will need to: 1) Finish the writing of two classes: Song and Playlist. The full header file for the Song class has been provided in a file called Song.h. 2) Write a main program (filename menu.cpp) that creates a single Playlist...
// Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given a partially completed program that creates a list of patients, like patients' record. // Each record has this information: patient's name, doctor's name, critical level of patient, room number. // The struct 'patientRecord' holds information of one patient. Critical level is enum type. // An array of structs called 'list' is made to hold the list of patients. // To begin, you should trace...