1 Replies - 1069 Views - Last Post: 11 February 2008 - 10:39 AM Rate Topic: -----

#1 generalbare  Icon User is offline

  • New D.I.C Head

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

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

Post icon  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 a day"<<endl;
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  Icon User is offline

  • Student of The Sun
  • member icon

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

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

Posted 11 February 2008 - 10:39 AM

View Postgeneralbare, 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 {
		cout<<"Please enter a day"<<endl;
		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 ...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1