PLEASE SOLVE THIS QUESTION USING SIMPLE JAVA CODING
Answer:
I have written the program based on your requirements.
The code works perfectly and it has no-error.
Output:
***********************************************************************************************************************************
Code:
import java.io.*;
import java.util.*;
import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
class test
{
public static void main(String[] args)
{
String q1="Select the town the
parcel will be delivered to \n1) Cape Town \n2) Pretoria\n3)
Durban";
String q2="Select the weight
category of the parcel to be delivered to: ";
String q3="Select the courier
company to deliver the parcel weight of ";
JFrame frame=new JFrame();
try
{
String
city="";
int
a=Integer.parseInt(JOptionPane.showInputDialog(frame,q1));
if(a==1)
{
q2=q2+"Cape Town";
city="Cape Town";
}
if(a==2)
{
q2=q2+"Pretoria";
city="Pretoria";
}
if(a==3)
{
q2=q2+"Durban";
city="Durban";
}
q2=q2+"\n1) 0kg - 4kg \n2) 5kg -
9kg \n3) Over 10kg";
int
b=Integer.parseInt(JOptionPane.showInputDialog(frame,q2));
String weight="";
double cost=0;
if(b==1)
{
q3=q3+"0kg - 4g"
+ " to Cape Town \n1) ABC Couriers \n2) Fast Track \n3) Rest
Assured";
weight="0kg -
4kg";
cost=300.00;
}
if(b==2)
{
q3=q3+"5k -
9kg"+ " to Pretoria \n1) ABC Couriers \n2) Fast Track \n3) Rest
Assured";
weight="5kg -
9kg";
cost=500.00;
}
if(b==3)
{
q3=q3+"Over
10kg"+" to Durban \n1) ABC Couriers \n2) Fast Track \n3) Rest
Assured";
weight="Over
10kg";
cost=700.00;
}
int
c=Integer.parseInt(JOptionPane.showInputDialog(frame,q3));
String courier="";
if(c==1)
{
courier="ABC Couriers";
}
if(c==2)
{
courier="Fast
Track";
}
if(c==3)
{
courier="Rest
Assured";
}
double vat=cost*0.14;
double total=cost+vat;
DateTimeFormatter pattern =
DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
LocalDateTime t = LocalDateTime.now();
System.out.println("\n\nDELIVERY
REPORT - Created on "+pattern.format(t));
System.out.println("\n*****************************************************");
System.out.println("\n\nTOWN:
"+city);
System.out.println("\n\nWEIGHT:
"+weight);
System.out.println("\n\nPRICE:
"+cost);
System.out.println("\n\nVAT (14%) :
"+vat);
System.out.println("\n\nTOTAL DUE :
"+total);
System.out.println("\n\nCOURIER:
"+courier);
System.out.println("\n*****************************************************");
}
catch(Exception e)
{
System.out.println("Exception Occurred - Enter Details Correctly
!!!");
}
}
}
PLEASE SOLVE THIS QUESTION USING SIMPLE JAVA CODING Fast and Secure is a logistics company specialising...