Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in a class FlowerCounter that computes the cost of flowers sold

ID: 3646521 • Letter: W

Question

Write a program in a class FlowerCounter that computes the cost of flowers sold at a flower stand. Five kinds of flowers - petunia, pansy, rose, violet, and carnation - are stocked and cost, respectively, 50, 75, 1.50, 50, and 80 cents per flower. create an array of strings that holds the names of these flowers. Create another array that holds the cost of each corresponding flower. Your program should read the name of a flower and the quantity desired by the customer. Locate the flower in the name array and use that index to find the cost per stem in the cost array. Compute and print the total cost of the sale.

PLEASE PROVIDE FULL PROGRAM IN JAVA LANGUAGE FOR 5 STARS RATING!

Explanation / Answer

import java.io.*;
class FlowerDemo
{
public static void main(String args[])

{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int quant=0;
String flower_name=" ";
String[] flower=new String[5];
flower[0]="petunia";
flower[1]="pansy";
flower[2]="rose";
flower[3]="violet";
flower[4]="carnation";
double[] cost=new double[5];
cost[0]=50;
cost[1]=75;
cost[2]=1.5;
cost[3]=50;
cost[4]=80;

try{
System.out.println("enter the name of the flower");
flower_name=br.readLine();
System.out.println("enter the quantity");
quant=Integer.parseInt(br.readLine());
}
catch(Exception e)
{
System.out.println(e);
}
int i=0;
while(i>-1)
{
if((flower_name).equals(flower[i]))
break;
else
i++;
}
System.out.println(i);
System.out.println("the totalcost is"+(quant*cost[i]));
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote