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

A Florist needs a program to manage his flower shop. The florist sells three typ

ID: 3761010 • Letter: A

Question

A Florist needs a program to manage his flower shop. The florist sells three types of flowers Viola, Rose and Camellia. The available flowers in the shop are 25, 33, and 40 respectively. The program should ask the customer to enter the type of flower (V or v for Viola. R or r for Rose, and C or c for Camellia) and the number of flowers to be bought. If the number of flowers to be bought is larger than the available flowers then display the message ''Sorry, we do not have this amount of flowers''. Otherwise display the following message.

Explanation / Answer

Solution :

package com.chegg.nancy.solutions;

import java.util.Scanner;

public class PickFlower {

   public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
       // Recieve input from user
       System.out.println("Enter the type of flower : Viola(V/v),Rose(R/r),Camellia(C/c)");
       String flower = scan.next();
       System.out.println("Enter the number of flower : ");
       int num = scan.nextInt();

       // Logic With Conditions
       if (flower.equalsIgnoreCase("V")) {
           if (num <= 25)
               System.out.println("Thank you come again.");
           else
               System.out.println("Sorry! We don not have this amount of flower.");

       } else if (flower.equalsIgnoreCase("R")) {
           if (num <= 33)
               System.out.println("Thank you come again.");
           else
               System.out.println("Sorry! We don not have this amount of flower.");

       } else {
           if (num <= 40)
               System.out.println("Thank you come again.");
           else
               System.out.println("Sorry! We do not have this amount of flower.");
       }
       // close the open resources.
       scan.close();
   }

}

Output:

Enter the type of flower : Viola(V/v),Rose(R/r),Camellia(C/c)
v
Enter the number of flower :
3
Thank you come again.

OR

Enter the type of flower : Viola(V/v),Rose(R/r),Camellia(C/c)
R
Enter the number of flower :
45
Sorry! We do not have this amount of flower.

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