| | |
please help me - extremely clueless :(
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2004
Posts: 26
Reputation:
Solved Threads: 0
hi all, i need urgent help. i am currently learning c++ and i have been given a program to write, I am really struggling with it and as it is an assignment whic needs to be handed in tomorrow i really need help
- im not lazy its just that im not grasping the concept very well at the moment and my tutor is too damn strict, wont give me help directley related to the assignment, can someone please help me out - below is the problem in detail. i am using the bloodshed compiler - http://www.bloodshed.net
I have to write a program that calculates charges for long-distance telephone calls according to the following scheme:
The regular charge rate is £1.50 for the first three minutes (or part thereof) and 30 pence for any minute after the first three. Rates are reduced during certain times of the day according to the following:
Monday to Friday
Before 8 a.m - 40% discount
8.am to 6pm (inclusive - regular rate)
after 6 pm - 40% discount
Saturday and Sunday
60% discount applies
the input to the program is to consist of the day on which the call was begun, the starting time of the call and the end time of the call. No call is to be greater than ten hours in duration.
the day is to be indicated by using a key letter: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
the times are to be entered to the nearest minute using 24 hour clock format. each time should consist of two parts - hours and minutes. midnight is 00 hours and 00 minutes. 1.35 pm is represented as 13 hours and 35 minutes.
the program is to display the day of the week as a full name, the call duration in minutes and the total charge.
The program should execute in a loop and so consideration must be given to how the processing requirements are to end.
complete the program by including a summary analysis which will determine the total number of calls made, the total duration of the calls and the total cost of all the calls made
many thanks in advance
- im not lazy its just that im not grasping the concept very well at the moment and my tutor is too damn strict, wont give me help directley related to the assignment, can someone please help me out - below is the problem in detail. i am using the bloodshed compiler - http://www.bloodshed.netI have to write a program that calculates charges for long-distance telephone calls according to the following scheme:
The regular charge rate is £1.50 for the first three minutes (or part thereof) and 30 pence for any minute after the first three. Rates are reduced during certain times of the day according to the following:
Monday to Friday
Before 8 a.m - 40% discount
8.am to 6pm (inclusive - regular rate)
after 6 pm - 40% discount
Saturday and Sunday
60% discount applies
the input to the program is to consist of the day on which the call was begun, the starting time of the call and the end time of the call. No call is to be greater than ten hours in duration.
the day is to be indicated by using a key letter: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
the times are to be entered to the nearest minute using 24 hour clock format. each time should consist of two parts - hours and minutes. midnight is 00 hours and 00 minutes. 1.35 pm is represented as 13 hours and 35 minutes.
the program is to display the day of the week as a full name, the call duration in minutes and the total charge.
The program should execute in a loop and so consideration must be given to how the processing requirements are to end.
complete the program by including a summary analysis which will determine the total number of calls made, the total duration of the calls and the total cost of all the calls made
many thanks in advance
•
•
Join Date: Dec 2004
Posts: 26
Reputation:
Solved Threads: 0
this is what i have so far
I have the validation working so that it does not allow any calls to be more than 10 hours (600 minutes) long. But now i need to start using do while and nested if loops and i havn't got a clue where to start, if someone has a similar problem or examples of code - doesnt have to be this question specific, i can still work from that - i just don't know how to write from scratch..
please help..
C++ Syntax (Toggle Plain Text)
#include <stdio.h> const float hi_rate=1.50; const float norm_rate=0.30; const float max_dur=600; char day; int st_hr, end_hr, st_min, end_min, call_dur, total_calls, total_dur; float call_cost, total_cost; main() { /* printf("\n\t\tDay of call: "); scanf("%",&day);*/ printf("\n\t\tEnter Call Start Hour: "); scanf("%d",&st_hr); printf("\n\t\tEnter Call Start Minute: "); scanf("%d",&st_min); printf("\n\t\tEnter Call End Hour: "); scanf("%d",&end_hr); printf("\n\t\tEnter Call End Minute: "); scanf("%d",&end_min); getchar(); call_dur=(end_hr - st_hr)*60 + end_min-st_min; if (call_dur < max_dur) { /*printf("\n\t\tday was: % ",day);*/ printf("\n\t\tDuration of call was %d minutes ",call_dur); printf("\n\t\tCost of call was %d ",call_cost); } else printf("\n\t\tCall time exceeded"); getchar(); }
I have the validation working so that it does not allow any calls to be more than 10 hours (600 minutes) long. But now i need to start using do while and nested if loops and i havn't got a clue where to start, if someone has a similar problem or examples of code - doesnt have to be this question specific, i can still work from that - i just don't know how to write from scratch..
please help..
Last edited by alc6379; Dec 13th, 2004 at 7:35 pm.
•
•
Join Date: Dec 2004
Posts: 26
Reputation:
Solved Threads: 0
well - i just need help in knowing how to structure them, i mean i think i have understood the problem but just cannot seem to put it in code correctly - there is lots of validation that needs to be done and i cant figure how/where it should go.
for example - when entering a day, you only enter one letter but the output must be the full day name - i have no idea how to do this, there is sumthing i have found which is using the SWITCH statement, but i can't get it to work
like that piece of code will do what i want.. with the exception that i cannot enter a letter, i need to enter either 1-7 to display what i need - is there a better way of doing this using if statements? i dont know
for example - when entering a day, you only enter one letter but the output must be the full day name - i have no idea how to do this, there is sumthing i have found which is using the SWITCH statement, but i can't get it to work
C++ Syntax (Toggle Plain Text)
#include <stdio.h> main() { int i; printf("Enter a day "); scanf("%d",&i); switch (i) { case 1: printf("Monday"); break; case 2: printf("Tuesday"); break; case 3: printf("Wednesday"); break; case 4: printf("Thursday"); break; case 5: printf("Friday"); break; case 6: printf("Saturday"); break; case 7: printf("Sunday"); break; default: printf("Day Not Recognised"); getchar(); } getchar(); getchar(); }
like that piece of code will do what i want.. with the exception that i cannot enter a letter, i need to enter either 1-7 to display what i need - is there a better way of doing this using if statements? i dont know
•
•
Join Date: Dec 2004
Posts: 26
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by frrossk
Yes, sure...Your code works on my compiler; except you should use int main () . What kind of errors dou you get?
I need to enter a single letter to display a day name .. ie
M= monday
U= tuesday
W= wednesday
T= thursday
F= friday
A= saturday
S= sunday
the switch i have got is fine, but it doesn't allow me to enter a character to display the name, it only allows me to use numbers 1-7 (which are the cases) I don't know if switch will accept characters in the case identifier as i cannot get it to work, i was wondering if there is any other way of doing what i want - ie - displaying a full day name from a single keystroke.. (make any sense)
C++ Syntax (Toggle Plain Text)
char i; //... scanf("%c", &i); //... case 'w': case 'W': printf("Wednesday"); break; //...
Good enough?
![]() |
Similar Threads
- pow: DOMAIN error (C++)
Other Threads in the C++ Forum
- Previous Thread: from gcc to VC++.Net
- Next Thread: confused how to begin this program
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib library linker list loop looping loops map math matrix memory microsoft newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template templates test text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






