## In Focus

AuthorQuestion
Programming Exercises
Posted on 26 Apr 2009

6.  Shipping Charges

The Fast Freigh Shipping Company charges the following rates:

Weight of Package                                 Rates per pound

2 pounds or less                                    \$1.10

over 2 pounds but not more than 6 lbs.   \$2.20

over 6 pounds but not more than 10 lbs.  \$3.70

Over 10 pounds                                    \$3.80

Design a program that asks the user to enter the weight of a package and then displays the shipping charges.

Rewrite If-Then-Else If statement as a Select Case statement.
If selection == 1 Then
Display "You selected A,"
Else If selection == 2 Then
Display "You selected 2"
Else If selection == 3 Then
Dsplay "You selected 3."
Else If selection == 4 Then
Display "You selected 4."
Else
Display "Not good with numbers, eh?
End If

2.  Design an If-Then-Else statement or a flowchart with a dual alternative decsion structure that display "Speed is normal" if the speed variable is within the range of 24 to 56. If speed holds a value outside this range, display "Speed is abnormal."

These are 2 of the questions we need to do. There are 2 more/
• 0
• 0
Re: Programming Exercises
Posted By Stefan on 26 Apr 2009

• 0
• 0
Re: Programming Exercises
Posted on 26 Apr 2009

We have to write an algorithm for my son (who is handicapp) computer programming class at IIT. It says to rewrite the following If-Then-Else If statement as a Select Case statement. This is how it is in the book

If selection == 1 Then

Display "You selection A."

Else If selection == 2 Then

Display "you selected 2."

Else If selection == 3 Then

Display "You selected 3."

Else If selection == 4 Then

Display "You selected 4."

Else

Display ot good with numbers, eh?"

End If

Rewrite If-Then-Else If statement as a Select Case statement.
If selection == 1 Then
Display "You selected A,"
Else If selection == 2 Then
Display "You selected 2"
Else If selection == 3 Then
Dsplay "You selected 3."
Else If selection == 4 Then
Display "You selected 4."
Else
Display "Not good with numbers, eh?
End If

2.  Design an If-Then-Else statement or a flowchart with a dual alternative decsion structure that display "Speed is normal" if the speed variable is within the range of 24 to 56. If speed holds a value outside this range, display "Speed is abnormal."

These are 2 of the questions we need to do. There are 2 more/
• 0
• 0
Re: Programming Exercises
Posted on 27 Apr 2009
Hi,

I think you need some thing like below

`   `
`            Console.WriteLine("Fast Freigh Shipping Company ");            `
`            Console.WriteLine("\n 1. 2 pounds or less\n 2.over 2 pounds but not more than 6 lbs\n 3.over 6 pounds but not more than 10 lbs.  \n 4.Over 10 pounds ");`
`            Console.WriteLine("\nSelect your weight category");`
`                switch (val)`
`                {`
`                    case 1: Console.WriteLine(" \$1.10"); break;`
`                    case 2: Console.WriteLine("\$2.20"); break;`
`                    case 3: Console.WriteLine("\$3.70"); break;`
`                    case 4: Console.WriteLine("\$3.80"); break;`
`                    default: Console.WriteLine("Invalid Option"); break;`
`                }`

`ORsomething like below`

`            Console.WriteLine("Fast Freigh Shipping Company ");`
`            Console.WriteLine("Enter your weight");`
`            int val1 = int.Parse(Console.ReadLine());`
`                        if(val1<=2)`
`                            Console.WriteLine(" \$1.10");`
`                        else if(val1>2 && val1<=6)`
`                            Console.WriteLine("\$2.20");`
`                        else if(val1>6 && val1<=10)`
`                            Console.WriteLine("\$3.70");`
`                        else if (val1 > 10)`
`                            Console.WriteLine("\$3.80");I hope this will help you.`

Happy to Learn
Vimal Kandasamy
• 0
• 0
Re: Programming Exercises
Posted on 27 Apr 2009

The first one about the freight company is under our programming exercises. We are to write a program using this information.

The other one we are to write an If-Then-Else algorith using the information given about the numbers and using the Case structure.

Thanks

Rosalie

Rewrite If-Then-Else If statement as a Select Case statement.
If selection == 1 Then
Display "You selected A,"
Else If selection == 2 Then
Display "You selected 2"
Else If selection == 3 Then
Dsplay "You selected 3."
Else If selection == 4 Then
Display "You selected 4."
Else
Display "Not good with numbers, eh?
End If

2.  Design an If-Then-Else statement or a flowchart with a dual alternative decsion structure that display "Speed is normal" if the speed variable is within the range of 24 to 56. If speed holds a value outside this range, display "Speed is abnormal."

These are 2 of the questions we need to do. There are 2 more/