a.
Explanation of Solution
Program:
File name: “Alphabetize.java”
//Import necessary header files
import java.util.*;
//Define a class named Alphabetize
public class Alphabetize
{
//Define main method
public static void main(String[] args)
{
//Declare the variables
String str1, str2, str3;
//Create an object for the Scanner class
Scanner in = new Scanner(System.in);
//Prompt the user to enter the first string
System.out.print("Enter first string >> ");
str1 = in.nextLine();
//Prompt the user to enter the second string
System.out.print("Enter second string >> ");
str2 = in...
b.
Explanation of Solution
Program:
File name: “Alphabetize2.java”
//Import necessary header files
import java.util.*;
//Define a class named Alphabetize2
public class Alphabetize2
{
//Define main method
public static void main(String[] args)
{
//Declare the variables
String str1, str2, str3;
//Create an object for the Scanner class
Scanner in = new Scanner(System.in);
//Prompt the user to enter the first string
System.out.print("Enter first string >> ");
str1 = in.nextLine();
//Prompt the user to enter the second string
System.out.print("Enter second string >> ");
str2 = in.nextLine();
//Prompt the user to enter the third string
System.out.print("Enter third string >> ");
str3 = in.nextLine();
//Check if the Strings were entered in alphabetical order
if(str1.toLowerCase().compareTo(str2.toLowerCase()) < 0)
if(str2.toLowerCase().compareTo(str3.toLowerCase()) < 0)
//Print the result
System.out.println(str1 + " " + str2 + " " + str3);
else
if(str3...
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Mindtap Computing, 1 Term (6 Months) Printed Access Card For Farrell’s Java Programming, 8th
- Write an application that accepts three Strings from the user and displays them in alphabetical order without regard to case.arrow_forwardThe 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_forward5. You are playing a game that has two dice - one die has 6 sides numbered 1 through 6 and the second die has 8 sides numbered 1 through 8. A turn involves rolling both die together. Write Java code to play 1,000 turns and keep track of the sum of the two dice in each roll I.e, (2 through 14). When all 1,000 turns have been completed, print a formatted table showing the value of the sum of the two dice (2 through 14) and the number of times that value occurred.arrow_forward
- X609: Magic Date A magic date is one when written in the following format, the month times the date equals the year e.g. 6/10/60. Write code that figures out if a user entered date is a magic date. The dates must be between 1 - 31, inclusive and the months between 1 - 12, inclusive. Let the user know whether they entered a magic date. If the input parameters are not valid, return false. Examples: magicDate(6, 10, 60) -> true magicDate(50, 12, 600) –> falsearrow_forwardQuestion 2 [50 points]: Write a Java program that reads from the user the result of a match between 2 teams in the FIFA World Cup in a single line. Then computes and prints the winning team or indicates that the teams tied! Test your code when the winning team is the first one, when the winning team is second one and when the match is drawn. Hint: The user should insert the 4 values in the same line using only one prompt message. Sample run1: Insert the result of the match: England 1 2 Italy Italy is the winning team Sample run2: Insert the result of the match: Brazil 1 1 Argentina Brazil and Argentina tied! Sample run3: Insert the result of the match: England 3 1 Brazil England is the winning teamarrow_forwardCreate a program that reads integers from the user until the enter key is pressed. Onceall of the integers have been read your program should display all of the negativenumbers, followed by all of the zeros, followed by all of the positive numbers. Withineach group the numbers should be displayed in the same order that they were enteredby the user. For example, if the user enters the values 3, -4, 1, 0, -1, 0, and -2 thenyour program should output the values -4, -1, -2, 0, 0, 3, and 1. Your programshould display each value on its own line.arrow_forward
- . 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_forwardCreate a program that: 1. Prompts the user to enter a string. 2. Use ANY method you'd like to remove all the vowels from the string (string function substring, accessing the string characters as arrays, etc.), creating a new string. 3. Output the new string with all the vowels removed. 4. The program MUST contain two functions-- (1) to remove all the vowels from the string, i.e., create a new string from the old string; (2) to determine if a character is a vowel. 5. Use an enumerated type to evaluate each character to determine if it is a vowel. Hint: Write the program WITHOUT the enumerated type first to get it working.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
- In Python Write the following application on a separate .py document. Write a program that computes the fuel efficiency for a multi-leg journey. The program will first prompt for the starting odometer reading and then get information about a series of legs. For each leg, the user enters the current odometer reading and the amount of gas used (separated by a space). The user signals the end of the trip with a blank line. The program should print the miles per gallon achieved on each leg and the total MPG for the trip.arrow_forwardJava program:; User's name. Write a program that prompts for and reads the user's first and last name (separately). Then print a string composed of the first letter of the user's first name, followed by the first five characters of the user's last name, followed by a random number in the range 10 to 99. Assume that the name is at least five letters long. Similar algorithms are sometimes used to generate user names for new computer accounts. wwwarrow_forward The fields below repeat for each customer: o Customer name (String)o Customer ID (numeric integer) o Bill balance (numeric)o EmailAddress (String)o Tax liability (numeric or String) The customers served by the office supply store are of two types: tax-exempt or non-tax- exempt. For a tax-exempt customer, the tax liability field on the file is the reason for the tax exemptions: education, non-profit, government, other (String). For a non-tax exempt customer, the tax liability field is the percent of tax that the customer will pay (numeric) based on the state where the customer’s business resides. Program requirements: From the information provided, write a solution that includes the following: A suitable inheritance hierarchy which represents the customers serviced by the office supply company. It is up to you how to design the inheritance hierarchy. I suggest a Customer class and appropriate subclasses.. For all classes include the following: o Instance variables o…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT