GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 23-Sep-2008, 00:24
L_i_o_n L_i_o_n is offline
New Member
 
Join Date: Sep 2008
Posts: 4
L_i_o_n has a little shameless behaviour in the past

Total the amount of hours in each month


Okay I need to modify the following program so that I can total the amount of hours in each month rather than generalize it to 744. Do you know how I could do that I wrote this program and got this now how could I modify it help?

CPP / C++ / C Code:
#include<iostream>
using namespace std;

int main()
{
	char choice;
	double charges;
	int hours;
	int number;
	double saveB;
	double saveC;



	cout << "This program calculates your monthly bill based on which package you used. " <<endl;
	cout << "The list of packages are as followed." << endl;
	cout << "Package A: $9.95 a month 10 hours access provided $2.00 additional hours after 10." <<endl << endl;
	cout << "Package B: $14.95 a month 20 hours access provided $1.00 additional hours after 20." << endl << endl;
	cout << "Package C: $19.95 a month unlimited access. " << endl << endl;
	cout << "Enter the package you are using with A,B, or C." << endl;
	cin  >> choice;
	


	switch(choice)
	{
	case 'A': cout << "How many hours were used? " <<endl;
			cin >> hours;
			if (hours > 744)
			  cout << "Its not possible to use that many hours in a month." <<endl;
			if (hours > 0 && hours < 10)
			   cout << "Your charges are $9.95 have a nice day. " <<endl;
			if (hours > 10 && hours <= 12)
			{
			number = hours - 10;
			charges = 9.95 + 2 * number;
			cout << "Your charges are $" << charges << " have a nice day." << endl;
			}
			if (hours > 12 && hours <= 15)
			{
			number = hours - 10;
			charges = 9.95 + 2 * number;
			cout << "Your charges are $" << charges << " have a nice day." << endl;
			saveB = charges - 14.95;
			cout << "If you had package B you would save $" << saveB << endl;
			}
			if (hours > 15 && hours <= 744)
			{
			number = hours - 10;
			charges = 9.95 + 2 * number;
			cout << "Your charges are $" << charges << " have a nice day." << endl;
			saveC= charges - 19.95;
			cout << "If you had package C you would save $" << saveC << endl;
			}

			break;

	case 'B': cout << "How many hours were used? " <<endl;
			cin >> hours;
			if (hours > 744)
				cout << "Its not possible to use that many hours in a month." << endl;
			if (hours > 0 && hours < 20)
				cout << "Your charges are $14.95 have a nice day. " << endl;
			if (hours > 10 && hours <= 25)
			{
				number = hours - 20;
				charges = 14.95 + 1 * number;
				cout << "Your charges are $" << charges << " have a nice day." << endl;
			}
			if (hours > 25 && hours <= 744)
			{
				number = hours - 20;
				charges = 14.95 + 1 * number;
				cout << "Your charges are $" << charges << " have a nice day." << endl;
				saveC= charges - 19.95;
				cout << "If you had package C you would save $" << saveC << endl;
			}


			break;

	case 'C': cout << "Your charges are 19.95 by your package plan." << endl;
			break;

	default:	cout << "You did not enter any of the above choices." << endl;

		break;


	}
	


		system ("Pause");

		return 0;

}
  #2  
Old 23-Sep-2008, 00:51
ocicat ocicat is offline
Regular Member
 
Join Date: May 2008
Posts: 580
ocicat is a jewel in the roughocicat is a jewel in the rough

Re: I need help again :(


Quote:
Originally Posted by L_i_o_n
Okay I need to modify the following program so that I can total the amount of hours in each month rather than generalize it to 744.

According to your initial post:
Quote:
Write a program that asks for the starting time and the number of minutes of call...
Given that you know the date in which each call is made, you have the information needed to determine in what month any particular call is made. How you save the information depends upon the course level (Is this an introductory course or something more advanced?). Not knowing anything about the expectations or what material you have covered, you could be saving all input to an array, file, or linked list. With any of these options, you will need to traverse however the information was stored given specific knowledge of what month is to be summarized.
  #3  
Old 29-Sep-2008, 03:46
Peter_APIIT Peter_APIIT is offline
Regular Member
 
Join Date: May 2007
Location: Malaysia
Posts: 545
Peter_APIIT can only hope to improve

Re: Total the amount of hours in each month


Query input from user seems a good choice.
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:53.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.