Question

Fast and Secure is a logistics company specialising in the delivery of products to Cape Town, Pretoria and Durban. The compan

Input ? Select the town the parcel will be delivered to 1) Cape Town 2) Pretoria 3) Durban OK Cancel Input Select the weight

PLEASE SOLVE THIS QUESTION USING SIMPLE JAVA CODING

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

I have written the program based on your requirements.

The code works perfectly and it has no-error.

Output:

C:\Users\Public>javac test.java C:\Users\Public>java test DELIVERY REPORT Created on 2020/07/31 19:25:43 TOWN: Durban WEIGHT:

х Input ? Select the town the parcel will be delivered to 1) Cape Town 2) Pretoria 3) Durban 31 OK Cancel

***********************************************************************************************************************************

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 !!!");
       }
      
      
   }
}

Add a comment
Know the answer?
Add Answer to:
PLEASE SOLVE THIS QUESTION USING SIMPLE JAVA CODING Fast and Secure is a logistics company specialising...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT