Question
Create a new Java class called: PriceList Write a price-look up program for a florist. The program should ask the user to enter the name
Create a new Java class called: PriceList
Write a price-look up program for a florist. The program should ask the user to enter the name of a flower. Next, the program should print to the screen the price of the flower. The price should be displayed to the screen with a dollar sign, and two decimal places. If the flower is not found in the price list, then the program should print the message "That flower was not found in the price list".
The flowers sold by this florist, along with their prices are as follows:
aconitum - $5.00 | brassica - $5.00 | eryngium - $10.00 | iris - $2.00 |
agpanthus - $6.00 | carthamus - $4.00 | eustoma - $5.00 | larkspur - $4.00 |
alstroemeria - $3.50 | chrysanthemum - $5.00 | freesia - $2.50 | lilium - $5.00 |
antirrhinum - $3.50 | cymbidium - $45.00 | gerbera - $4.00 | nerine - $3.00 |
aster - $4.00 | delphinium - $8.00 | gladiolus - $3.00 | rose - $3.50 |
asterspray - $3.00 | dendrobium - $4.00 | helianthus - $3.00 | tulip - $2.50 |
bird of paradise - $62.00 | dianthus - $2.00 | hydrangea - $8.00 |
The program should store the names of the flowers in an array of Strings, which will be declared as a global constant named FLOWERS. Remember that you can create an array and initialize it with values all at the same time by using the notation:
String [] FLOWERS = {name1, name2, name3};
Make sure that you list the flowers in alphabetical order in the array in order to pass the automated tests.
The program should store the prices of the flowers in an array of doubles, which will be declared as a global constant named PRICES. Make sure that the price positions match up to the flower name positions.... in other words if the "aconitum" is stored in position 0 of the FLOWERS array, then it's price of $5.00 should be stored in the same position (pos 0) in the PRICES array.
The following is an example of what your MIGHT see on the screen when your program runs. The exact output depends on what values that the user types in while the program runs. The user's values are shown below in italics:
Enter the name of the flower: Gerbera The price is: $4.00
Here is another example run of the program:
Enter the name of the flower: daffodil That flower was not found in the price list
In order to pass the tests:
Your program must print the correct wording, with the correct spacing, and the correct output
The user should be able to type in any combination of upper and lowercase letters
Your program must have global constants named FLOWERS and PRICES
The flowers and prices arrays must contain the correct values in the correct order
NO BREAK STATEMENTS TO EXIT LOOPS SHOULD BE USED
STARTING CODE:
import java.util.*;
public class PriceList {
public static Scanner kbd; public static final String [] FLOWERS = {}; public static final double [] PRICES = {}; public static void main(String[] args) { kbd = new Scanner(System.in); kbd.close(); }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started