Concept explainers
a.
Explanation of Solution
Program:
File name: “StringSort.java”
//Import necessary header files
import java.util.*;
import javax.swing.*;
//Define a class named StringSort
public class StringSort
{
//Define main method
public static void main(String[] args)
{
//Create an array of 15 string values
String[] values = {"mouse", "dog", "cat", "horse", "cow",
"moose", "tiger", "lion", "elephant", "bird", "hamster",
"guina pig", "leopard", "aardvark", "hummingbird"};
//Declare the variable
...
b.
Explanation of Solution
Program:
File name: “StringSort2.java”
//Import necessary header files
import java.util.*;
import javax.swing.*;
//Define a class named StringSort2
public class StringSort2
{
//Define main method
public static void main(String[] args)
{
//Create an array of 15 string values
String[] values = new String[15];
//Declare the variables and initialize the values
int x = 0;
int count = 0;
String word;
final String QUIT = "zzz";
//Declare a Boolean variable and initialize the value
boolean didUserQuit = false;
/*For loop is executed until x exceeds the length of the given values*/
for(x = 0; x < values.length; ++x)
values[x] = QUIT;
//Assign value 0 to x
x = 0;
//While x is less than the length of the given values
while(x < values.length)
{
//Prompt the user to enter a word
word = JOptionPane.showInputDialog(null, "Enter a word or " +
QUIT + " to quit");
//If the user enters zzz
if(word.equals(QUIT))
{
count = x;
x = values...
Trending nowThis is a popular solution!
- 1. Create an java program containing an array that stores 20 prices, such as $2.34, $7.89, $1.34, and so on. The application should -display the sum of all the prices, -display all values less than $5.00, -calculate the average of the prices, and -display all values that are higher than the calculated average value.arrow_forwardArrays where the index is a string value. O a. Associative O b. Positive O c. Numeric O d. Nonearrow_forward3. Randomly generate a number in range [1, 12]. Map this number to a season: if the number is 3, 4, or 5, map it to “Spring", if the number is 6, 7, or 8, map it to "Summer", if the number is 9, 10, or 11, map it to "Fall", and if the number 12, 1, or 2, map it to "Winter". Display season namearrow_forward
- Programming in C#: Write a console-based application that displays every perfect number from 1 through 10000. A number is perfect if it equals the sum of all the smaller positive integers that divide evenly into it. For example, 6 is perfect because 1, 2, and 3 divide evenly into it and their sum is 6. Use format strings(field size 8, right alignment) to show all perfect numbers. Display the results as seen below. 6 28 496 8128arrow_forwardIt is an array of references to string objects.a. string arrayb. character arrayc. ragged arrayd. indexed arrayarrow_forwardInstructions: 1. This java program is for an application that stores the author (Writer) data of some books and emails. 2. getAuthors() method get the list of authors and store it in a String array. 3. addAuthors() method is used to add an author anytime for book or email. 4. getDate() method get the date of the book or email. 5. getTitle() method can be used to get the title of the book. 6. getSubject() method is used to get the Subject of the email. 7. getTo() method is used to get the information about the mail to whom it is sent. 8. All get methods need to return the values in the corresponding instance variables. 9. Scanner class can be used to set the data for the variables. The programmer can give his/her own methods to set the instance variablesarrow_forward
- Create a program named SalesTaxDemo that declares an array of 10 Sale objects. Prompt the user for data for each object and display the 10 objects. The program should accept input and display output in the same format as the sample program output below. Data fields for Sale objects include: InventoryNumber - An inventory number (as a string) amount - Amount of the sale (as a double) tax - Tax owed (as a double) Include a property with get and set accessors for the first two data fields, but make the tax owed a read-only property. The tax should be calculated whenever the amount of the sale is set. Assume that the tax rate is 8 percent for the first $100 and 6 percent for any amount greater than $100. In C#arrow_forwardIn C#, Write a program named CheckZips that is used by a package delivery service to check delivery areas. The program contains an array that holds the 10 zip codes of areas to which the company makes deliveries. (Note that this array is created for you and does not need to be changed.) Prompt a user to enter a zip code, and display a message indicating whether the zip code is in the company’s delivery area. For example if the user enters a zip code in the array, such as 60007, the output should be Delivery to 60007 ok. If the user enters a zip code not in the array, such as 60008, the output should be Sorry - no delivery to 60008.arrow_forwardAll coding is done in Java. I am using IntelliJ Idea if it helps. 12. Bar Chart Write a program that asks the user to enter today's sales for five stores. The program should display a bar chart comparing each store's sales. Create each bar in the bar chart by displaying a row of asterisks. Each asterisk should represent $100 of sales. Example: Enter today's sales for store 1: 1000 [Enter] Enter today's sales for store 2: 1200 [Enter] Sales Bar Chart Store 1: ********** Store 2: ************arrow_forward
- Write an application that stores the following nine integers in an array: 10, 15, 19, 23, 26, 29, 31, 34, 38. Display the integers from first to last, and then display the integers from last to first.arrow_forwardWrite a code segment that searches a Grid object for a negative integer. The loop should terminate at the first instance of a negative integer in the grid, and the variables row and column should be set to the position of that integer. Otherwise, the variables row and column should equal the number of rows and columns in the grid. *Pythonarrow_forward4. Ascend! by CodeChum Admin Hey I’ve got this cool idea for an app! It’s kind of simple but just hear me out. All the user has to do is enter a bunch of integers. Then the application prints the largest sum of a strictly ascending sequence of the array. A strictly ascending sequence is a sequence where the current number is always lesser than the next number. For example, the user enters 2 4 5 1 7 3, the output should be 11 (2 + 4 + 5). Then that’s it! I think this is going to be a hit! Don’t you think? Well I do. If you help me then we’re going to be rich! Note: For this problem, a sequence must contain at least 2 numbers. If there is no sequence found, then the largest sum is 0. Input 1. The size of the array Constraints The value is within the range: 0 <= size <= 2147483647 2. Elements of the array Constraints Each element <= 2147483647 and >= 0 Output The first line will contain a message prompt to input the size. The succeeding lines will…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT