import java.io.*;
public class XYZSupermarket {
static String productCode = null;
static String pricingCode = null;
static Double price;
static int quantityOfArticle;
static String address = null;
static boolean nightshipping ;
static void enterData() throws IOException
{
BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
System.out.println("Enter the product code:");
productCode = br.readLine();
System.out.println("Enter the pricing code:");
String pricingCode = br.readLine();
System.out.println("Enter the price:");
price = Double.parseDouble(br.readLine());
System.out.println("Enter the quantity of an article:");
quantityOfArticle = Integer.parseInt(br.readLine()) ;
System.out.println("Enter the adress:");
address = br.readLine();
checkingForOvernightShipping();
}
static void checkingForOvernightShipping() throws IOException
{
System.out.println("Enter Y if you want overnight shipping or N if you dont want");
BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
String temp = br.readLine();
if (temp.equals("Y")||temp.equals("y"))
nightshipping = true;
else
nightshipping = false;
}
static void outputData()
{
System.out.println("Product code is "+productCode);
System.out.println("Pricing code is "+pricingCode);
System.out.println("Price is "+price+" $");
System.out.println("Quantity of an article is "+quantityOfArticle);
System.out.println("Adress is "+address);
calculatingPrice();
}
static void calculatingPrice()
{
price*=quantityOfArticle;
if (price<100)
{
price += 20.00;
System.out.println("Regular shipping is 20.00 $");
}
else
{
price += 30.00;
System.out.println("Regular shipping is 30.00 $");
}
if(nightshipping)
{
price += 50.00;
System.out.println("Overnight delivery is $50.00 $");
}
System.out.println("The total discounted price " +price);
}
public static void main(String[] args) throws IOException {
enterData();
outputData();
}
}
Comments
Leave a comment