Click here to Skip to main content
16,006,006 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Create a font from the resource file Pin
Scott H. Settlemier26-Nov-02 8:10
Scott H. Settlemier26-Nov-02 8:10 
Questionhow do you kill a dialog? Pin
trustno125-Nov-02 14:53
trustno125-Nov-02 14:53 
AnswerRe: how do you kill a dialog? Pin
Chris Losinger25-Nov-02 15:01
professionalChris Losinger25-Nov-02 15:01 
GeneralRe: how do you kill a dialog? Pin
trustno125-Nov-02 21:03
trustno125-Nov-02 21:03 
GeneralListview images in LVS_REPORT mode Pin
trimtrom25-Nov-02 13:37
trimtrom25-Nov-02 13:37 
GeneralRe: Listview images in LVS_REPORT mode Pin
Roman Fadeyev25-Nov-02 18:24
Roman Fadeyev25-Nov-02 18:24 
GeneralRe: Listview images in LVS_REPORT mode Pin
trimtrom26-Nov-02 9:27
trimtrom26-Nov-02 9:27 
GeneralPhone Bill Pin
Autunmsky25-Nov-02 13:28
Autunmsky25-Nov-02 13:28 
I'm trying....to write a program to compute phone bill with discounts and taxes....I got stumped though... I can't have the time with a 60 in it....How do I go about putting this in my code...and I need to compute to Taxes....I need to compute for before the taxes are added in with discounts where needed and with the tax after wards....any help would be grateful....

thanks

Julie Confused | :confused:



// Purpose: Write a program that computes a phone bill for long distance. Program will ask user to input the number of calls to process.
// Then for each call the user will input the start time for a call based on a 24-hour military time clock and
// length of the call in minutes. The program then will compute and print the cost fo the call, before and after
// the tax has been added. Tax will be computed after discounts (where needed).




#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

const float REGULAR_RATE = 0.20f;
const float AFTER_BEFORE = 0.25f;
const float LONGER_SIXTY = .15f;


void DisplayOpeningScreen();
void PrintBlankLines(int);
void PrintTotalBeforeTax(float, int);
void PrintTotalAfterTax(float, int);


int main()
{

int numofCalls;
int callCount;
int startTime;
int lengthinMin;
float sumofCalls;
float callcost;
float discrate1;
float discrate2;
float doubleDisc;

DisplayOpeningScreen();


cout << "How many phone calls will be processed? ";
cin >> numofCalls;

PrintBlankLines(2);

callCount = 0;
sumofCalls = 0;
while (callCount < numofCalls)
{

cout << "The start time of the call in military time is: ";
cin >> startTime;
cout << endl;

while (startTime > 2359 || startTime <0 )
{
cout << "Error.....please enter a vaild start time: \n";
cin >> startTime;
}


cout << "The length of the call in minutes is: ";
cin >> lengthinMin;
cout <<endl;

="" while="" (lengthinmin="" <="" 1)
="" {
="" cout="" <<="" "error....please="" enter="" a="" vaild="" length="" time:="" \n";
="" cin="">> lengthinMin;
}

callcost = lengthinMin * REGULAR_RATE;

if (startTime >= 1800 || startTime < 800)
{
cout << "The call receives a 25% discount\n";
discrate1 = (lengthinMin * AFTER_BEFORE) - float(callcost) ;
cout << "The call with the discount is: " << discrate1 << endl;
}

if (lengthinMin >= 60)
{
cout << "The call receives a 15% discount\n";
discrate2 = float(callcost) - (lengthinMin * LONGER_SIXTY);
cout << "The call with the discount is: " << discrate2 << endl;
}

if (startTime >= 1800 || startTime < 800 && lengthinMin >+60)
{
doubleDisc = discrate1 + discrate2;
cout << "This call receives both a 15% discount and a 25% discount.\n";
cout << "The call with both discounts is: " << doubleDisc << endl;

}





callCount++;

}

PrintTotalBeforeTax(callcost, numofCalls);


return 0;
}

//****************************************************************************************************************************************

void DisplayOpeningScreen()

// Purpose: Explains the program to the user
// Pre: None

{

cout << "/n \"Long Distance Phone Bills\"\n";

PrintBlankLines(3);

cout << "This Program will start by asking you the user to enter the number of calls to be processed. Then you will be asked " << endl;
cout << "to enter the start time for each call based on a 24-hour (military time) clock and the length of the call in minutes.\n\n";

cout << "The program will then compute and print the cost of the call, before and after the federal tax has been addded. Any and all\n";
cout << "discounts will be computed before the federal tax.\n\n";

cout << "The Rate Structure for long distance calls is as follows:\n\n";

cout << " * The regular rate for a call is $" << REGULAR_RATE << " per minute " << endl;
cout << " * Any call started at or after 6:00p.m. (1800 hours) but before 8:00a.m. (800 hous)\n";
cout << " receives a 25% discount" << endl;
cout << " * Any call longer than 60 minutes receives a 15% discount on its cost (after the start\n";
cout << " time discount is subtracted, if appropriate)" << endl;
cout << " * All calls are subject to 4% federal tax, which is computed after the discounts\n\n";


PrintBlankLines(4);
system("pause");
system("cls");

}


//******************************************************************************************************************************************

void PrintBlankLines(/*in*/ int numLines)

// Purpose: Print numLines blank lines on the output screen
// Pre: numlines > 0

{

int lineCt;

lineCt = 1;

while (lineCt <= numLines)

{
cout << endl;
lineCt++;
}

}


//******************************************************************************************************************************************

void PrintTotalBeforeTax(/*in*/ float callcost, /*in*/ int numofCalls)

// Purpose: Prints the total cost of all of the calls inputed by user with out federal tax added on.
// Pre: callcost >= 0.00, num >= 0

{

system("pause");
system("cls");



PrintBlankLines(8);

cout << " Final Totals Before Tax\n\n";
cout << " Number of Calls Processed: " << numofCalls << endl;
cout << " Total amount of calls before tax: " << callcost << endl;

PrintBlankLines(9);

}

//********************************************************************************************************************************************
GeneralRe: Phone Bill Pin
Christian Graus25-Nov-02 14:46
protectorChristian Graus25-Nov-02 14:46 
GeneralRe: Phone Bill Pin
Autunmsky25-Nov-02 14:59
Autunmsky25-Nov-02 14:59 
GeneralRe: Phone Bill Pin
Christian Graus25-Nov-02 15:06
protectorChristian Graus25-Nov-02 15:06 
GeneralRe: Phone Bill Pin
Autunmsky25-Nov-02 15:31
Autunmsky25-Nov-02 15:31 
GeneralRe: Phone Bill Pin
Christian Graus25-Nov-02 15:39
protectorChristian Graus25-Nov-02 15:39 
GeneralRe: Phone Bill Pin
Autunmsky25-Nov-02 15:48
Autunmsky25-Nov-02 15:48 
GeneralRe: Phone Bill Pin
Christian Graus25-Nov-02 15:57
protectorChristian Graus25-Nov-02 15:57 
GeneralRe: Phone Bill Pin
Autunmsky25-Nov-02 16:09
Autunmsky25-Nov-02 16:09 
GeneralRe: Phone Bill Pin
Christian Graus25-Nov-02 16:15
protectorChristian Graus25-Nov-02 16:15 
GeneralRe: Phone Bill Pin
Autunmsky25-Nov-02 16:27
Autunmsky25-Nov-02 16:27 
GeneralRe: Phone Bill Pin
Autunmsky25-Nov-02 16:34
Autunmsky25-Nov-02 16:34 
GeneralRe: Phone Bill Pin
Christian Graus25-Nov-02 16:40
protectorChristian Graus25-Nov-02 16:40 
GeneralRe: Phone Bill Pin
Autunmsky25-Nov-02 16:44
Autunmsky25-Nov-02 16:44 
GeneralRe: Phone Bill Pin
Christian Graus25-Nov-02 16:48
protectorChristian Graus25-Nov-02 16:48 
GeneralCreateBitmap problem Pin
Anonymous25-Nov-02 13:16
Anonymous25-Nov-02 13:16 
GeneralRe: CreateBitmap problem Pin
Christian Graus25-Nov-02 13:26
protectorChristian Graus25-Nov-02 13:26 
GeneralRe: CreateBitmap problem Pin
Anonymous25-Nov-02 13:39
Anonymous25-Nov-02 13:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.