|
||||||||||
|
|
#1 (permalink) |
|
Googler
![]() Join Date: Dec 2008
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Switch Statement
Code:
#include <iostream.h>
#include <iomanip.h>
void main()
{
int shippingmethod;
double shippingcost;
cout<<"How do you want the order shipped?\n";
cout<<"1- Ground\n";
cout<<"2- 2-day air\n";
cout<<"3= Overnight air\n";
cout<<"4- Carrier Pigeon\n";
cout<<"Enter the number of the shipping method you want: ";
cin>>shippingmethod;
switch(shippingmethod)
{
case 1:
shippingcost=5.00;
break;
case 2:
shippingcost=7.50;
break;
case 3:
shippingcost=10.00;
break;
case 4:
shippingcost=230.00;
break;
default:
shippingcost=0;
break;
}
if (shippingcost==0)
{
cout<<"Illegal selection--no result calculated"<<endl;
}
else
{
cout.setf(ios::fixed);
cout<<"Add $"<<setprecision(2)<<shippingcost<<" to the order total to cover shipping cost."<<endl;
}
}
Last edited by wolfyy1; 05-28-2009 at 05:03 AM. |
|
|
|
|
Sponsored Links
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Switch between windows? | Rockin | Introduce Yourself | 0 | 05-02-2008 08:59 AM |
| Forum Software Switch? | intelliot | GC Announcements | 30 | 07-14-2006 01:31 AM |
| Why switch? | ajordan | Gmail Forum | 16 | 07-04-2006 06:20 AM |
| search line switch | 9BallNinja | Search Engine Optimization Forum | 0 | 03-07-2006 11:06 AM |