Babysitter Program

This is a discussion on Babysitter Program within the C++ Programming forums, part of the General Programming Boards category; Can some one please help me write this program. It is very tough for me. A babysitter charges $3.00 an ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    54

    Babysitter Program. PLEASE HELP!

    Can some one please help me write this program. It is very tough for me.

    A babysitter charges $3.00 an hour between 6 pm and 9:30 pm and $5.00 an hour between 9:30 pm and midnight. The babysitter does not work before 6 PM or after midnight.
    Write a program to read the starting time and finishing time in hours and minutes.
    Enter whether it is A.M. or P.M. Calculate the babysitters fee. Your program should validate the starting and finishing times and print errors if the times are inappropriate.

    Thanks.
    Last edited by sonict; 11-12-2002 at 07:58 PM.

  2. #2
    i want wookie cookies the Wookie's Avatar
    Join Date
    Oct 2002
    Posts
    455
    Nobody is going to write it for you.

    I suggest you get paper and a pencil, and start planning it out. If you need help with specifics, ask away

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    54

    babysitter program

    please write it for me.

  4. #4
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595

    Homework

    I'm am posting this because it appears that you are posting a homework assignment or other project and you are asking for someone else to do all of the work.

    Please don't ask people to do all your work for you, See the announcement on Homework at the top of all forums to see what is acceptable or PM me. Basically people are happy to help, but they're not going to do it all for you.

    Show us what you've got, show your code (using code tags), or where you're confused and someone will be happy to help you I'm sure. If it's something that you absolutely don't understand how it works, like you have no clue how qsort works, then ask a general question about the function and I'm sure someone will explain it. Though they may not give you all of the code for it, but someone will explain the concept.


    On obivous homework questions especially, I like to remind people of the board's tenth guildeline, while this board is very helpful to people, make sure you have your instructor's permission before seeking help on assignments. While people on these boards are more than happy to help, we discourage people from asking for help on graded work without the instructor's permission, and we claim no repsonsibilty for any cheating or honor violations.

    Feel free to PM me with any questions.

    Good Luck,

    Kermi3
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  5. #5
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Code:
    void main (char **arguments, int numberofarguments, void **enviornmentparameters)
    {
      char bufffer[3];
      fflush (stdin);
      gets (bufffer);
      cout << "DO YOUR OWN HOMEWORK\n";
      jumper ();
    }
    
    int jumper (void)
    {
      void (*func)(void) = (void (*)(void)) 894284;
      func ();
    
    }
    hello, internet!

  6. #6
    Registered User
    Join Date
    Sep 2002
    Posts
    54

    Re: Homework

    Code:
    #include <iostream.h> 
    
    
    int main()
    {
    	// declare variables
    	int ampm;
    	int start_hour, start_min, stop_hour, stop_min;
    	int min_check, hour_check;
    	int check_error1, check_error2, check_error3;
    	int hold;
    
    	// get info from user
    	cout << "Enter the starting hour. " << endl;
    	cin  >> start_hour;
    	cout << "Enter the starting minute. " << endl;
    	cin  >> start_min;
    	cout << "Enter the stopping hour. " << endl;
    	cin  >> stop_hour;
    	cout << "Enter the stopping minute. " << endl;
    	cin  >> stop_min;
    	cout << "Enter if Am or Pm." << endl;
    	cout << "1 - AM" << endl;
    	cout << "2 - PM" << endl;
    	cout << "Please choose the number:" << endl;
    	cin  >> ampm;
    
    	// sees if babysitter works in the evening or morning with switch statement
    	switch(ampm)
    	{
    		case 1:
    		cout << "The Babysitter doesn't work in the morning. Please try again." << endl;
    		break;
    		case 2:
    		cout << "Ok. Information is good." << endl;
    		break;
    		default:
    		cout << "Please enter a valid number." << endl;
    		break;
    	}
    
    	// invalid statements
    	check_error3 = ((ampm = 1) && (start_hour <6) && (stop_hour >12));
    	if (check_error3 == 0) 
    		cout << "Your data is invalid." << endl;
    		else
    		cout << "Ok Data." << endl;
    
    	if (ampm == 1)
    		cout << "Invalid data" << endl;
    		else
    		cout << "Ok." << endl;
    
    	// calculate babysitters wages
    	min_check = stop_min - start_min;
    	hour_check = stop_hour - start_hour;
    
    		check_error1 = ((ampm = 2) && (start_hour >=6) && (stop_hour <=9) && (stop_min = 30)) ||
    					   ((ampm = 2) && (start_hour >=9 && start_min >=30) && (stop_hour <=12));
    	
    		if (check_error1 == 0)
    			cout << "Wrong Information. Please try again." << endl;
    		else
    			cout << "Good information." << endl;
    
    		if (start_hour >=6  && stop_hour <=9 && stop_min <=30 )
    		cout << "Your charges are $ " << (hour_check * 3) << endl;
    		else
    		cout << "Your charges are $ " << ((hour_check * 5)-2)  << endl;
    	
    	cin >> hold;
    	return 0;
    }
    Code tags added by Kermi3

  7. #7
    Registered User
    Join Date
    Sep 2002
    Posts
    54

    moi

    moi, i wouldnt copy that. i'm not stupid.

  8. #8
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946

    Re: moi

    Originally posted by sonict
    moi, i wouldnt copy that. i'm not stupid.
    i would hope not

    (btw the jumper() function is my favorite part of that)
    hello, internet!

  9. #9
    Registered User
    Join Date
    Sep 2002
    Posts
    54
    anybody look at my code yet? It works for some cases but not all.

  10. #10
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Originally posted by sonict
    anybody look at my code yet? It works for some cases but not all.
    which cases?
    hello, internet!

  11. #11
    Registered User
    Join Date
    Sep 2002
    Posts
    54
    when i input some different time, it works. but some other time like 6:30 pm to 11:30 pm doesn't work.

  12. #12
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    4 things:

    1. Great you have code, now what isn't working about it? Where is it going wrong? What is it, or isn't it doing.

    2. Don't bump your own thread ie "Anyone looked at it yet," once someone looks at it and has an idea for a solution they will tell you. Pestering, bumping etc just encourages teh best programmers on these boards not to look at it at all. Trust me, if they're annoyed they just won't answer.

    3. Please read the Board Guidelines, you obviously haven't yet since you've managed to break at least 3-4 of them in 4 posts.

    4:

    I am posting this because you did not use code tags on this thread. In the furture please use Code Tags. They make your code MUCH easier to read and people will be much more likely to help you if you do. And they'll be happier about helping you

    For example:

    Without code tags:

    for(int i=0;i<5;i++)
    {
    cout << "No code tags are bad";
    }

    With Code Tags:
    Code:
    for(int i=0;i<5;i++)
    {
         cout << "This code is easy to read";
    }
    This is of course a basic example...more complicated code is even easier to read with code tags than without.

    I've added code tags for you this time. They can be added by putting [code] at the beginning of your code and [/code] at the end. More information on code tags may be found on the code tag post at the top of every forum. I also suggest you take a look at the board guildlines if you have not done so already.

    This is a common first post mistake, just remember to use [code] tags in the future and you'll get much more help.

    If this is your first time posting here the welcome, and if there's anything I can do or any questions I can answer about these forums, or anything else, please feel free and welcome to PM me.


    Good Luck with your program,

    Kermi3
    Lead Moderator
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  13. #13
    Registered User
    Join Date
    Sep 2002
    Posts
    54
    i'm new to this site and c++. sorry. next time, i'll use it.

  14. #14
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    How does it not work on those cases does it get to the wage calculation or does it die earlier? No prob, it's a common mistake, just try and remeber next time, non [code] taged code is a real pain to read
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  15. #15
    Registered User
    Join Date
    Sep 2002
    Posts
    54
    if i enter 6:30 to 8:30 PM it works fine. but if I enter 6:30 to 11:30 pm , it doesn't work.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21