I have an assignment on a phone bill and I am havig a hardtime understacnding the time aspect of my program. does any one know where I can get help in the tutorials.
I have an assignment on a phone bill and I am havig a hardtime understacnding the time aspect of my program. does any one know where I can get help in the tutorials.
Jessica
>I am havig a hardtime understacnding the time aspect of my program
Well, what would the time aspect of your program be? We're not exactly mind readers.
-Prelude
My best code is written with the delete key.
I have to do a phonebill with the information in a data file. and I have to use military time and I am always getting errors where the : is.
I am not completely finished yet but here it is
[code]
#include <iostream>
#include <fstream>
#include <cctype>
void getinfo(int&length, double& time, double& cost, char& day, char& day2)\
;
void showbill(int length, double time, double cost, char day, char day2);
int main()
{
using namespace std;
char ans;
do
{
int length;
double time, cost;
char day, day2;
getinfo(length, time, cost, day, day2);
showbill(length, time, cost, day, day2);
cout << "Do you want to recalculate your phone bill again (y/n):";
cin >> ans;
cout << endl;
}while (ans == 'Y' || ans == 'y');
cout << "Thank you good bye.\n\n";
return 0;
}
void getinfo(int& length, double& time, double& cost, char& day, char& day2)
{
using namespace std;
ifstream in;
in.open("/home1/c/a/acsi201/samples/phonedata");
double costd, coste, costw, weekendrate = 0.15, eveningrate = 0.25, dayr\
ate = 0.45;
char M,O,T,U,W,E,H,F,R,S,A;
cost == length * dayrate;
cost == length * eveningrate;
cost == length * weekendrate;
toupper (('m' && 'o') ||
('t' && 'u') ||
('w' && 'e') ||
('t' && 'h') ||
('f' && 'r'));
if ((day == M && day2 == O) ||
(day == T && day2 == U) ||
(day == W && day2 == E) ||
(day == T && day2 == H) ||
(day == F && day2 == R))
if (time >= 1 && time < 13 )
cout << coste;
else if ((time <= 18) || (time >= 8))
cout << costd;
}
void showbill(int length, double time, double cost, char day, char day2)
{
using namespace std;
cout << " Day Time Cost \n";
cout << day << time << cost;
}
Jessica
I guess my main question would be is do i use a decimal point (14.59) instead of a colon (14:59) to represent military time 2:59 pm
Jessica
I'm confused as to why you can't simply do this.
cout << var1 << ":" << var2 << endl;
Obviously var1 & var2 are not from your program but you get the idea.
I can use this even if the variable are coming from a data file
Jessica
Um, I'd have to see the program. What you posted above is not enough for me to really see what is happening. Maybe you could comment out that part where you would like the cout to be and attach the zip to your post. I will try to look at it then, or post the entire source in the [C_ODE] // blah [/C_ODE] tags, without the underscore.
Well, one thing to look at is where you're declaring using namespace std; It only needs to be declared once, and that's underneath your includes but before any function blocks.