A company is supplying 5 types of soft drinks like Pepsi, Sprite, Orange Soda, Cherry Soda and a new lemon drink to different stores. The company has a new promotion which gives a free dozen of lemon drink and free dozen of cherry drink for every 24 dozen of Pepsi, for every 30 dozen of Sprite and every 10 dozen of Orange Soda. The company provides many discounts on their sales which can be listed as follows:-

• 2% discount if sale >=$15,000
• 3% discount if sale>=$20,000
• 2% additional discount if the bill is paid within 30 days
• 10 dozens of free lemon drinks extra if the total purchased is>= $25,000.
Write a program in java to read the order for the number and type of soft drinks, soda cost, and shipping and handling cost, date of invoice, payment date. Then compute the total discount, total number dozens of soda, total number of free soda received, shipping cost, and total cost. Use String tokenizer and buffering. Must document the program and provide the processing phase of the program.
For this problem, use the following data
5000 doz Pepsi
4000 doz Sprite
7500 doz Orange Soda
$1.50 per dozen
$0.25 shipping cost per dozen.

import java.util.Scanner;

public class Vend {

public static void main(String[] args) {
int sodaCost;
int amount = 0;
int freeLemon = 0;
int freeCherry = 0;
int freeSoda;
int totalSoda;
double discount;
double price = 0;
double discountedPrice;
double totalCost;
double shipHandCost;
final double PRICE_PER_DOZEN = 1.50;
final double SHIP_PER_DOZEN = .25;

String type = "";
Scanner sc = new Scanner(System.in);
//

System.out.println("Enter amount of soda (in dozens): ");
amount = sc.nextInt();

//

System.out.println("Enter type of soda: ");
type = sc.next();
//
if(type.equals("Pepsi")){
freeLemon = amount / 24;
freeCherry = amount / 24;

}else if(type.equals("Sprite")){
freeLemon = amount / 30;
freeCherry = amount / 30;
}else if(type.equals("Orange Soda")){
freeLemon = amount / 10;
freeCherry = amount / 10;
}else{
freeLemon = 0;
freeCherry = 0;
}
//
shipHandCost = SHIP_PER_DOZEN * amount;
price = PRICE_PER_DOZEN * amount;
freeSoda = freeLemon + freeCherry;
totalCost = shipHandCost + price;
totalSoda = amount + freeSoda;
if(totalCost >= 15000){
discount = .02;
discountedPrice = price * discount;
}
if(totalCost >= 20000){
discount = .03;
discountedPrice = price * discount;
}else
discountedPrice = price;
System.out.println("Total Cost : " + totalCost);
System.out.println("Discounted Cost " + discountedPrice);
System.out.println("Total number of free sodas for the order (in dozens): " + freeSoda);
System.out.println("Total number of dozens of sodas (in dozens): " + totalSoda);


sc.close();

}

}

To solve this problem, we can break it down into smaller steps and write a program to perform each step. Here is a step-by-step explanation of how to approach this problem:

1. Read the order details from the user:
- Number and type of soft drinks (Pepsi, Sprite, Orange Soda) - need to be read for each type separately.
- Soda cost - given as $1.50 per dozen.
- Shipping and handling cost - given as $0.25 per dozen.
- Date of invoice and payment date.

2. Compute the total number of dozens of soda:
- Multiply the number of dozens for each type of soda by the respective quantity ordered.
- Add the results for Pepsi, Sprite, and Orange Soda.

3. Compute the total discount:
- Check if the sale meets the conditions for any of the discount categories.
- If the sale is greater than or equal to $15,000, apply a 2% discount.
- If the sale is greater than or equal to $20,000, apply a 3% discount.
- If the bill is paid within 30 days, apply an additional 2% discount.

4. Compute the total number of free soda received:
- For every 24 dozen of Pepsi, provide a free dozen of lemon drink.
- For every 30 dozen of Sprite, provide a free dozen of cherry drink.
- For every 10 dozen of Orange Soda, provide a free dozen of lemon drink.

5. Compute the shipping cost:
- Multiply the total number of dozens of soda by the shipping cost per dozen ($0.25).

6. Compute the total cost:
- Subtract the total discount from the total cost of soda and shipping.

7. Output the results:
- Display the total discount, total number of dozens of soda, total number of free soda received, shipping cost, and total cost.

Here is a Java code example that implements the above steps:
```java
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.StringTokenizer;

public class SoftDrinkOrder {
public static void main(String[] args) {
// Read the order details
int pepsiOrder = 5000;
int spriteOrder = 4000;
int orangeSodaOrder = 7500;
double sodaCostPerDozen = 1.50;
double shippingCostPerDozen = 0.25;

// Compute total number of dozens of soda
int totalDozens = pepsiOrder + spriteOrder + orangeSodaOrder;

// Compute total discount
double totalDiscount = 0;
if (totalDozens * sodaCostPerDozen >= 15000) {
totalDiscount += totalDozens * sodaCostPerDozen * 0.02;
}
if (totalDozens * sodaCostPerDozen >= 20000) {
totalDiscount += totalDozens * sodaCostPerDozen * 0.03;
}

// Additional discount for paying within 30 days
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date invoiceDate = new Date();
Date paymentDate = new Date(); // Set your payment date here
long daysBetween = (paymentDate.getTime() - invoiceDate.getTime()) / (1000 * 60 * 60 * 24);
if (daysBetween <= 30) {
totalDiscount += totalDozens * sodaCostPerDozen * 0.02;
}

// Compute total number of free soda received
int freeLemonDrink = pepsiOrder / 24 + orangeSodaOrder / 10;
int freeCherryDrink = spriteOrder / 30;

// Compute shipping cost
double shippingCost = totalDozens * shippingCostPerDozen;

// Compute total cost
double totalCost = totalDozens * sodaCostPerDozen + shippingCost - totalDiscount;

// Output results
System.out.println("Total Discount: $" + totalDiscount);
System.out.println("Total Dozens of Soda: " + totalDozens);
System.out.println("Total Free Lemon Drink: " + freeLemonDrink);
System.out.println("Total Free Cherry Drink: " + freeCherryDrink);
System.out.println("Shipping Cost: $" + shippingCost);
System.out.println("Total Cost: $" + totalCost);
}
}
```

This program calculates the total discount, total number of dozens of soda, total number of free soda received, shipping cost, and total cost based on the given input order details. You can modify the order details and payment date to test different scenarios.