1. American Region P50.00 every 3 minutes
2. Asian Region P30.00 every 2 minutes
3. African Region P40.00 every 3 minutes
4. European Region P35.00 every 2 minutes
Nightime Calls:
1. American Region P45.00 every 3 minutes
2. Asian Region P27.00 every 2 minutes
3. African Region P36.00 every 3 minutes
4. European Region P30.00 every 2 minutes
Make a program that would input destination code (between 1 to 4 ), time code (1 for day, 2 for night), the duration of the call and output the total charges
Example output :
Enter Destination Code : 2
End Time Code : 1
Duration of the Call : 39
Asian Region . . . Day time call, the charge is P585.00
class CALL
{
float _length;
signed _dest;
signed _time;
public:
CALL (signed dest, signed time, float duration) : _length(duration), _dest(dest), _time(time) {}
float GetCost()
{
signed rate;
switch(_time)
{
case day:
switch(_dest)
{
case America:
rate = .5f;
break;
case Asia:
//Enter the rest here.
case Africa:
case Europe:
}
break;
case night:
switch(_dest)
{
case America:
case Asia:
case Africa:
case Europe:
}
break;
}
return rate * _length;
}
};
Finish this function, create an object with the correct constructor, and then just call GetCost()
A case statement is part of a switch statement. It basically is saying "in case america is selected, or asia, or africa" i dont know Turbo C but i assume some things are the same as C++. Case statements are basically if statements but they are more compact and easier to work with, can you imagine nesting 100 if statements!!! that would get tricky, complicated and wouldnt work well, the switch statement solves that problem. However i dont think you can use strings in a switch statement.