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.

1 answer

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();

}

}