Hello everyone

I am new with algorithm, this is one of my problem which I am trying to sort out. Can anyone help me with some clues for this...

Design an algorithm that will read an input weight for an item to be shipped search an array of shipping weights and retrieve a corresponding freight charge.

Then write a program to implement the algorithm using a 6 element array/s.

Recommended Answers

All 4 Replies

Welcome to the forum, Anzoo! ;)

Here's the way to use the forum - give your assignment a good try, and then post your try. Tell us what has you stumped.

If we don't do that, we become "homework coders" for everyone (or so it seems), and the students can't learn much that way, either.

You'll need to create an array of integers with two numbers on each row. Set the array values to correspond to 1) the weight and 2) the shipping charge, on each row.

Then you can scan the array with a

while (package weight < shipping weight number[i++]);

1 line while loop. Sweet! :)

and carry on from there.

Thanks a lot Adak, it worked finally :)

Hello everyone

I am new with algorithm, this is one of my problem which I am trying to sort out. Can anyone help me with some clues for this...

Design an algorithm that will read an input weight for an item to be shipped search an array of shipping weights and retrieve a corresponding freight charge.

Then write a program to implement the algorithm using a 6 element array/s.

ANSWER:

the important point is that when writing an algorithm we have to use line numbers,try to avoid the usage of program lines,will be readable.and start with START and end with END.........

the answer to your question is

ALGORITHM:

1 : start
2 : declare 'w' as weight of body,list[] as the array from which want to sort
3 : read the weight and store into a variable 'w'.
4 : take the each element of array one by one and compare with the weight of the body 'w'
5 : if the value of the body is equal to the the weight in the array print the corresponding price
6 :else print the weigt is not listed.
7 :END

it is a simple algorithm which want to start a program .if we want to deeply study the program using algorithm then we want to wright more specificly

commented: A very good point. Thanks jamalpp786 +0

Hi there
Thank you, I am getting it now, it is really nice to be in this community.
:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.