Thread: please I want from you help to do this home wrok

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    9

    Unhappy please I want from you help to do this home wrok

    hello every body here

    I am student in university and I need help for this home work because this homework

    my teacher he will give me big mark if I did it very well and I need for this mark to pass

    I tried to solve this home work but it very difficult for me I can't do it please I need the

    answer for this questions below:

    1-Write a program that prompts the user to enter the number of required lines to draw an incrementing series of stars. The user should stop if 0 is entered.
    Notice the stars are drawn after an indent of aproximately 2 taps.


    ++++++++++++++++++++++++++++++++++


    2-A parking garage charges a $2.00 minimum fee to park for up to three hours.
    The garage charges an additional $0.50 per hour for each hour or part of hour in excess of three hours. The maximum charge for any given 24 hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. Write a program that calculates and prints the parking charges for each of three customers who parked their cars in this garage yesterday.
    You should enter the number of hours parked for each customer. Your program should print the results in a neat tabular format and should calculate and print the total of yesterday's receipts. The program should use a function calculateCharges to determine the charge for each customer. Your output should appear in the following format:

    Enter the hours parked for three cars: 1.5 4.0 24.0

    Car Hours Charge
    1 1.5 2.00
    2 4.0 2.50
    3 24.0 10.00
    TOTAL 29.5 14.50
    Press any key to continue....

    ++++++++++++++++++++++++++++++++++++++++++
    Hints:
    • Use a for loop to prompt the user for the number of hours parked for each of the three customers.
    • Declare variables to store the total number of hours and the total charges for each customer.
    • The variables for all charges and numbers of hours should be of type double.
    Function calculateCharges should use a nested if/else structure to determine the customer charge.

    I wait you......

  2. #2
    Registered User rynoon's Avatar
    Join Date
    Dec 2006
    Location
    London, ON
    Posts
    26
    Could you post your code so far and explain your specific problems?

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    312
    Quote Originally Posted by student C++
    I tried to solve this home work but it very difficult for me
    Could you show us your attempts to solve the problem?

    Edit - Rynoon beat me to it that time!

  4. #4
    Registered User
    Join Date
    Jan 2007
    Posts
    9
    hi
    This code for question 1

    Code:
    #include<iostream>
    
    using namespace std;
    int main()
    {
    	int i;
    	for(i=0;i<=n;i++)
    		cout<<"Enter number of lines (press 0 to quit):"<<endl;
    
    	    
    		
    		if(n==0)
    			cout<<"\n";
    	cout<<"Good_Bye\n";
    		return 0;
    }

  5. #5
    Registered User
    Join Date
    Feb 2006
    Posts
    312
    That's a start I suppose. Did you try to compile it? You haven't declared n anywhere.

  6. #6
    Registered User rynoon's Avatar
    Join Date
    Dec 2006
    Location
    London, ON
    Posts
    26
    For question one you need to ask for the number of lines before you enter a loop. Consider the example output below.

    Code:
    Enter the number of lines (press 0 to quit): 4
    
      *
      **
      ***
      ****
    
    Goodbye
    This is what you're trying to create. How are you going to print an incrementing number of stars on each line?

  7. #7
    Registered User
    Join Date
    Jan 2007
    Posts
    9
    please help me I don't know stars
    Code:
    #include<iostream>
    
    using namespace std;
    int main()
    {
    	int i,j;
    	
    
    	
    
    	do{
    
    		cout<<"Enter number of lines (press 0 to quit):"<<endl;
    	    cin>>i;
    
    	    for(j=0;j<=i;j++)
    			
    			
    		* =(*+i);
    	
    
    	}while(i!=0);
    
    	cout<<"Good_Bye\n";
    
    		return 0;
    }

  8. #8
    Registered User
    Join Date
    Feb 2006
    Posts
    312
    Code:
    		* =(*+i);
    I'm not sure what you're doing here, but this isn't right!

    a star is just another character, so output it the same way you'd output any other text.

  9. #9
    Registered User rynoon's Avatar
    Join Date
    Dec 2006
    Location
    London, ON
    Posts
    26
    Alright. You have to remember that a * is just a char. What do you do when you want to !-->"string"<--! more than one char together?
    Last edited by rynoon; 01-05-2007 at 08:23 PM.

  10. #10
    Registered User
    Join Date
    Nov 2005
    Posts
    673

    here is a little code

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main() {
        int stars = 0;
        int t_val = 0;
        cout << "Enter the number of rows for incrementing stars: ";
        cin >> ____;
        for ( int x = 0; x != ____ + 1; ++x ) {
            int temp = 0;
            while ( x != temp ) {
                ++temp;
                ++____;
                cout << "*";
            }
            cout << endl;
        }
        cout << "Number of rows: " << t_val << endl;
        cout << "Total number of stars: " << stars << endl;
        system("pause");
    }
    I cut out a few sections so you will have to figure that part out, but if you add the right things back into it where there are underscores then this code works perfectly;

  11. #11
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Thw parking garage assignment is rather simple. Just a matter of passing the right argumement value back to the caller. You can solve almost all of this with if statements. I did somthing simular last year. One hint, use a loop to ensure the question if asked three times
    Double Helix STL

  12. #12
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    my teacher he will give me big mark if I did it very well and I need for this mark to pass
    Code:
    * =(*+i);
    For someone posting such random guesses at C++ syntax, it would be just plain wrong for your teacher to give you a pass at the moment. TANSTAAFL.
    I think Raigne gave you way more than anyone should have.

    Get yourself a good beginner C++ book or some absolute beginner web-based tutorials and spend some time learning the basics of the language.

  13. #13
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    Sorry about that, did I break the forum rules posting that if so I am sorry. Anyhow take iMalc's advice as it will do you alot of good. However if you are in college for programming why do you not notice the errors in your code?

  14. #14
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318

    Red face

    Quote Originally Posted by Raigne
    Sorry about that, did I break the forum rules posting that if so I am sorry. Anyhow take iMalc's advice as it will do you alot of good. However if you are in college for programming why do you not notice the errors in your code?
    Probably borderline yeah, but you didn't give the whole answer, he still has to solve the second bit. Its hard to resist the urg eh!
    Besides the teacher most likely need only ask him a basic question about his answer to determine that he doesn't understand it, and hence didn't write it.

    Be careful not to let the language barrier get used as an excuse to jump more quickly to posting code instead of discussing the program logic. They can choose to post elsewhere, and often have, so the difficulty of communicating with English speakers was their chosen disadvantage.

    I find that a general guideline is to never post more than about two consecutive lines of code in a response to homework. The bulk of it should be psuedo code and discussion.

    Be especially weary of first-time posters.

  15. #15
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    Ah, I will do well to remember that, and maybe only explanations or pointers on what to do for now on. thanks for the info iMalc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem in accessing root home folder....
    By Bargi in forum Linux Programming
    Replies: 1
    Last Post: 02-13-2008, 05:50 AM
  2. Hey I back home!!!
    By ssharish2005 in forum A Brief History of Cprogramming.com
    Replies: 88
    Last Post: 07-02-2007, 03:11 PM
  3. Change cwd to Home
    By Shogun in forum C Programming
    Replies: 2
    Last Post: 08-30-2004, 04:03 PM