I need your help 1 Answer(s) 3 years and 3 months ago
Posted in : Java Beginners
For this one I need to create delivery class for a delivery service .however, this class should contain (delivery number which contains eight digits. The first four digits represent the year; the last four represent the area. E.g, the 76th delivery in 2010 has a complete delivery number of 20100076). (Code to representing the delivery area either 1 for local delivery or 2 for long distance delivery). (Weight in kg of the item to be delivered).at the end the fee for the delivery as follows: Distance Weight Fee (RM) 1 Under 5 kg 12.00 1 5 ? 20 kg 16.50 1 Over 20 kg 22.00 2 Under 5 kg 33.00 2 5 kg or more 45.50
Create a constructor for the Delivery class that accepts arguments for the year, delivery number within the year, delivery distance code and weight of the package. The constructor determines the eight-digit delivery number. Also include these methods to (set the delivery fee, set and get every Delivery object field, display every Delivery object field) The file name is Delivery.java Next, create an application that prompts the user for data for a delivery. Keep prompting the user for each of the following values until they are valid: ? a four digit year between 2010 and 2025 inclusive ? a delivery number for the year between 1 and 9999 inclusive ? a package weight between 0.10 kg and 100 kg inclusive ? a delivery code distance that is either 1 or 2. When all data entries are valid, construct a Delivery object and then displays its values. The system will be terminated if the entry value for delivery code is -1. Save the file name is ApplicationDelivery.java Your program must follow proper Java standards, implement selection and repetition structure, and include comments to describe the purpose of the program.
View Answers
March 9, 2010 at 2:46 PM
Hi Friend,
Try the following code:
import javax.swing.*; import java.util.*; class Delivery { int year; int deliveryNo; double weight; int code;
Delivery(int year,int deliveryNo,double weight,int code){ year=year; deliveryNo=deliveryNo; weight=weight; code=code; } public double displayFees(int c,double w){ double fees=0; if(c==1){ if(w<5){ fees=12.00; } else if((w<20)&&(w>5)){ fees=16.50; } else if(w>20){ fees=22.00; } } else if(c==2){ if(w<5){ fees=33.00; } else if(w>=5){ fees=45.50; } } return fees; } } public class ApplicationDelivery{ public static void main(String []args){ Scanner input=new Scanner(System.in); System.out.print("Enter year: "); int y=input.nextInt(); while((y<2010)||(y>2025)){ System.out.println("Year should be in the range of (2010 - 2025)."); System.out.print("Please re-enter year: "); y=input.nextInt(); } System.out.print("Enter delivery no: "); int no=input.nextInt(); while((no<1)||(no>9999)){ System.out.println("Delivery No should be in the range of (1 - 9999)."); System.out.print("Please re-enter delivery no: "); no=input.nextInt(); } System.out.print("Enter weight: "); double w=input.nextDouble(); while((w<.10)||(w>1000)){ System.out.println("Weight should be in the range of (.10kg - 100kg)."); System.out.print("Please re-enter weight: "); w=input.nextDouble(); } System.out.print("Enter delivery code: "); int code=input.nextInt(); while((code<1)||(code>2)){ System.out.println("Code No should be either 1 or 2."); System.out.print("Please re-enter code: "); code=input.nextInt(); } String num=Integer.toString(no); String year=Integer.toString(y); if(num.length()==1){ num="000"+num; } else if(num.length()==2){ num="00"+num; } else if(num.length()==3){ num="0"+num; } String delNo=year+num; Delivery del=new Delivery(y,no,w,code); double fees=del.displayFees(code,w); System.out.println(code+" "+delNo+" "+w+" "+fees); } }
Thanks
Related Pages:
I need your help - Java Beginners Ineedyour help What is the purpose of garbage collection in Java, and when is it used? Hi check out this url :
http://www.artima.com/insidejvm/ed2/gc.html
http://java.sun.com/javase/technologies/hotspot
i need your help - Java Interview Questions ineedyour help Write a java program that:
i. Allows user to enter 2 numbers from the keyboard
ii. Uses a method to compare the two numbers to determine which is larger
iii. Print to the screen stating which number is larger
I need your help - Java Beginners Ineedyour help For this one Ineed to create delivery class for a delivery service .however, this class should contain (delivery number which... the file name is ApplicationDelivery.java
Your program must follow proper Java
hello there i need help
hello there ineed help : ineed to do a program like...:
YOur Balance is __
if i chose D:
Enter you deposit amount:
if i choose W... i am a beginner, and aside from that i am really eager to learn java please help
Need help in completing a complex program; Thanks a lot for your help Needhelp in completing a complex program; Thanks a lot for your help ... stuck:
Ineed to write a batch file (Windows) which will pass that string... no output. So please help me with this too.
And also, I am using Runtime function
I need help in doing this. - Java Beginners Ineedhelp in doing this. Student DataBase
i will need creating..., and the student's GPA.using arrays and objects, need to structure the information... objects that will house
the birthdates for each student member. (I have
i need a help in this please ineed a help in this please The factorial of a nonnegative integer n is written n! (pronounced â?? n factorialâ??)
and is defined as follows:
n!=n...=input.nextInt();
long num=m;
for(int i=m;i>1;i
I have need to help I have need to help Write a program that, for four points A, B, C and P, draws a triangle formed by ABC
and a small cross showing the position of P; and displays a line of text indicating which of
the following three cases
Need help with my project Needhelp with my project Uses a while loop to perform the following...
label between each section of output. Note that your program must be able to run...));
bw.newLine();
for(int i=firstNum;i<=secondNum;i
Need help in java programming Needhelp in java programming Hello.
Can someone please help me...;
do{
System.out.print("Please enter your choice: ");
menu = input.nextInt... StudentResult[2];
for (int i=0; i<data.length; i++) {
int j=i+1
i need help - Development process ineed help hello,
ineedhelp regarding this program. this program... IPAddress on command line, but i want to take it dynamically and it must store...?
hi subhash hope this code can help you,
public class PingTest
i need help - Development process ineed help hello,
ineedhelp regarding this program.
public...());
}
}
}
it is printing the result of ping in to a file,but if i want... the result in to the files,if i want to do this i must make my program running
i need help to solve this problem ineedhelp to solve this problem Write a stack class ArrayStack.java implements PureStack interface that reads in strings from standard input.... H and I join the queue
h. G leaves the queue
i. H and I leave the queue
i need help plz .... Quickly ineedhelp plz .... Quickly how can i count how many numbers enterd by the user so the output would be like this
Total number of Scores = ....
this is my code :-
import java.util.Scanner;
public class SCORES
{
public
Need help Need help Hello...
Ineed some helpI have a method which contains 1 string value and i wnat when this method get called den that string value should b assigned as array name..
for example..
i have a method name() which
Need help Need help Hello...
Ineed some helpI have a method which contains 1 string value and i wnat when this method get called den that string value should b assigned as array name..
for example..
i have a method name() which
Need help Need help Dear sir, I have a problem. How to write JSP coding, if a user select a value from drop down list for example department, the another drop.... This name list should get from the database. Please help me.
By the way, I'm
Need help with this! Needhelp with this! Can anyone please help me... to effectivly end the loop with out the need to break it.
for(i=(0); i <... to a file at all at this time. Any help would be greatly appreciated, thank you
Need help on mySQL 5 - SQL Needhelp on mySQL 5 Dear Sir,
I'm a beginner of mySQL 5 . Ineedhelp on mySQL5 command.
This is the table which i created is called... by using Aggregate function(MAX).
May i know that what command ineed
need to fix errors please help need to fix errors please help it does have 2 errors what should i...;
String name2;
System.out.println("please enter your name:");
name1= input.readline();
System.out.println("please enter your friend's name:");
name2
need
need ineed a jsp coding based project plz help me
Need help writing a console program Needhelp writing a console program Ineedhelp cant seems to figure...):
This is a test, this is only a test!
This test is a test of your Java programming... is what i got so far.
import java.io.File;
import java.util.Scanner;
public class
pls i need help with my assignment
pls ineedhelp with my assignment how to write a code that ask the user for the height of the triangle and prints the triangle using * eg if height is 3 it prints
*
and also using import java.util.Scanner
PLZ HELP ME. i need php code.
PLZ HELP ME. ineed php code. I want php code for bellow OUTPUT.
output is just example but it must be letters only.
abc
bcd
efg
jku
rgt
azs
hje
qqc
wws
adt
i need some help in understanding the following codes.thanks.. ineed some help in understanding the following codes.thanks.. this code is to perform LocalColorHistogram.But i can't understand it
public... * height;
int i = 0;
int j = 0;
int k = 0;
double
need help pleaseee....i weak in java needhelp pleaseee....i weak in java QUESTION 1
You are required to write an application called Customer Billing System. This system...) Separate them as either R/r for Residential or I/i for Industrial. You can use
This is what i need in this Question - Java Beginners
array.
so ineedyourhelp to know is it correct or wrong
Thank you...This is what ineed in this Question You are to choose between two... explaination with out coding
In my understanding I choose the non-empty array
need help on writing a program. - Java Beginners
Writing first Java Program Hi, Ineedhelp to write my first Java Program other then Hello World! Thanks!! Hi Thanks for choosing roseIndia to get your query solved. check given link to see the solution of your Java
Need Help on JMS - JMS NeedHelp on JMS Hi, In my application ineed to create my own ques and my own QueueConnectionFactory..... Plz tell me how to create the same... Any help is appriciated,.. Thanks in advance
Need help with nested queries Needhelp with nested queries Hello,
Table1 has "id", "votes" columns. Table2 has "id", "Name" column. Ineed to retrieve Name and its corresponging Votes. I tried with nested queries but its confusing. Can anyone please help
need help please needhelp please Dear sir, my name is logeswaran. I have a big problem that I can't find the solution for a program. How can I block a user from enter a page second time. Please help me.
By the way I'm using Access database
Need help in constructing a 2 dimensionla array? Needhelp in constructing a 2 dimensionla array? Construct a 2... i got but i dont know what im missing thanks in advance.
public class...[][];
for (int i=0; i
Here is an example of generating two-dimensional
need help to create applet needhelp to create applet Can u help me..??
I get a task ...and i dont know how to make it...
So I hope that u can help me...
Here is the task...
If u can help me, then please send it to my email
lcfahmi90@yahoo.com
http
need help creating a lift program - Java Beginners needhelp creating a lift program Classes, Methods, Constructors
please ineedhelp to create an elevator program
Simulating an Elevator
write..., ensuring that all your Elevator methods work successfully.
then add two constructors
Need help on JAVA JSP Needhelp on JAVA JSP Hi,
I have never worked on java and I have been given an assignment where I have to fix existing issues in the tool(created...(need to know how I can adjust it based on the cureen system's screen resolution
Need some help urgently Need some help urgently Can someone please help me with this below question. Ineed to write a class for this.
If you roll Y standard six-sided dice... about the probability of coming X or more number of 4's on Y number of dice. I
need help with java program as soon as possible needhelp with java program as soon as possible So my assignment...();
if(num1>num2){
System.out.print("Your First Number is greater than...("Numbers and their squares between 1 and 10");
int i=1;
while(i <= 10
need help - Java Beginners need help Needhelp in programming in Java Simple java...();DISPLAYING OUPUT " * " ," *** " ........I used System.out.print('"'); statement before System.out.print("*"); statement and I used
Need Help on the script NeedHelp on the script hello there,
My name is Femi and am a web developer using php. am working on a project. and am having some difficulties. i dont know if you can help me out with it.
The platform am building will receive
Need Help - Java Beginners Need Help Hello Sir,
Am a beginner of Java. Also i did course on J2EE... but dont have any ideas about real time projects.
But i want to do some projects in Java as well as J2EE...
Can u help me and guide to do a project
Need help - Java Beginners Need help To Write a Java program that asks the users to enter a m...; Hi Friend,
Please try the following code. We hope that this code will help...[]) {
int[][] arr = new int[4][4];
for (int i = 0; i <
seriously need help....
seriously needhelp.... Write a program that will prompt the user... for 30 days.
Constraints
Your program will be divided into four separate sub-programs defined as methods below. Use the methods appropriately in your
need help...................please needhelp...................please I have a problem in my JSP Coding. How to retrive value from database in to text field when user select one value... on this area. Please help me.
By the way, I'm using access Database and JSP coding
I need to develop a gui like this
please help me
sorry goes through this link
Ineed to develop like...Ineed to develop a gui like this Hai Friends,
Ineed to develop such a menu in my gui programs. The gui contains 1 text field.whenever the text
( Inheritance, Polymorphism, Overriding)i need help - Java Beginners
( Inheritance, Polymorphism, Overriding)ineed help Advanced Concepts with Classes( Inheritance, Polymorphism, Overriding)
ineedhelp to create this application,than you
Employees in a company are divided into the classes
need help with a program - Java Beginners needhelp with a program Part I An algorithm describes how... by the user. The output of the program should be the length and width (entered.... First you would need to make up the "test data". For this algorithm, the test data
HELP
HELP Ineed this code to open in a new web browser. but no matter what i do it wont please help??
Directive 055 Storage Requirements for the Upstream Petroleum Industry
need someone to do/help with code need someone to do/help with code ineed someone to do a code for me..., I want a second class that is able to tell the owner how much he made that day, along with the number of items sold..please help did a code 500 times cant
help
help ineedhelp with this code.
write a java code for a method named addSevenToKthElement that takes an integer array, and an integer k as its arguments and returns the kth element plus 7.
any help would be greatly