# Refer to Walter Savitch C++ a Problem Solving Approach 5e

Page 1 of 1

## 1 Replies - 1513 Views - Last Post: 11 February 2008 - 10:39 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=42954&amp;s=175b3c8a2ea0866da7b4ec3f54d0d4a1&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 generalbare

Reputation: 0
• Posts: 2
• Joined: 11-February 08

# Refer to Walter Savitch C++ a Problem Solving Approach 5e

Posted 11 February 2008 - 04:56 AM

Here is what my Problem is supposed to do:

Write a Program that computes the cost of long distance call. the cost of the call is determined as follows:
M-F 8am-6m cost: .\$60/minutes
otherwise \$ .25/min
Sat-Sun \$.15/min

Special rate 5 dollars

Proff modified problem text requirement and the problem statement is as above
Futher the proff wants me to limit number of hours to a maximam of two hours in all cases
Hour is put in twotwenty hour format

Here is my spaghetti code

#include <iostream.h>
#include <dos.h>
#include <iostream.h>
#include <conio.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>

#define cls cout << endl;system("cls")
#define pause cout << endl;system("pause")
#define ESC 27
void cost_structure_fuction(void);

void main (void)
{

cost_structure_fuction();
return;

}

void cost_structure_fuction(void);
{

int day;
double start_hour;
double end_hour;
double end_minute;
double start_minute;
double maximum_hours=0;
do
{
cout<<" Please enter in the start hour in 24:00 format"<<endl;
cin>>start_hour;
cout>>" Please enter in the start minutes"<<endl;
cin>>star_minute;
cout<<"Please enter in the end hour"<<endl;
cin>>end_hour;
cout>>"Please enter in the end minutes"<<endl;

maximum_hours=((start_end-star_hour)+((60-end_minute)*(1/60)) +((60-start_minute)*(1/60)))
cout<<"the maximum hour is"<<maximum_hours

}while( maximum_hours<=2);

switch(day)
{
case'01': case '02': case '03': case '04': case '05':
if ((8<=hour<=18)&&(day==(01)||(02)||(03)||(04)||(05)))
{
cost=(.60)*maximum_hours;
}
else
{

cost=(.25)*maximu_hours;
}
break;
case '6' :
break;
case '7':
cost=(.15)*(maximum_hours);
break;
default:

cost=5*(maximum_hours);

}

}

Is This A Good Question/Topic? 0

## Replies To: Refer to Walter Savitch C++ a Problem Solving Approach 5e

### #2 letthecolorsrumble

• Student of The Sun

Reputation: 27
• Posts: 555
• Joined: 07-November 07

## Re: Refer to Walter Savitch C++ a Problem Solving Approach 5e

Posted 11 February 2008 - 10:39 AM

generalbare, on 11 Feb, 2008 - 04:56 AM, said:

Here is what my Problem is supposed to do:

Write a Program that computes the cost of long distance call. the cost of the call is determined as follows:
M-F 8am-6m cost: .\$60/minutes
otherwise \$ .25/min
Sat-Sun \$.15/min

Special rate 5 dollars

Proff modified problem text requirement and the problem statement is as above
Futher the proff wants me to limit number of hours to a maximam of two hours in all cases
Hour is put in twotwenty hour format

Here is my spaghetti code

Well, here is my Pasta code :-)
```#include <iostream>

using namespace std;/*required for input and output commands*/

#define cls cout << endl;system("cls")
#define pause cout << endl;system("pause")
#define ESC 27

void cost_structure_fuction(void);

void main (void){
cost_structure_fuction();
return;
}

void cost_structure_fuction(void){

int day;
double start_hour;
double end_hour;
double end_minute;
double start_minute;
double maximum_hours=0;
double cost;
do {
cin>>day;
cout<<" Please enter in the start hour in 24:00 format"<<endl;
cin>>start_hour;
cout<<" Please enter in the start minutes"<<endl;
cin>>start_minute;
cout<<"Please enter in the end hour"<<endl;
cin>>end_hour;
cout<<"Please enter in the end minutes"<<endl;
cin>>end_minute;
maximum_hours=((end_hour-start_hour)+((60-end_minute)*(1/60)) +((60-start_minute)*(1/60)));
cout<<"the maximum hour is"<<maximum_hours;

}while( maximum_hours<=2);

switch(day){
case'01': case '02': case '03': case '04': case '05':
if ((8<start_hour&&start_hour<18)
&&(day==(01)||(02)||(03)||(04)||(05))){
cost=(.60)*maximum_hours;
}
else{
cost=(.25)*maximum_hours;
}
break;
case '6' :
break;
case '7':
cost=(.15)*(maximum_hours);
break;
default:

cost=5*(maximum_hours);
}
}

```

There are no compiling errors... you could apply your functions in the given code and see if it works... or post again ...