Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 28th, 2007, 7:00 PM   #11
Simplesouljah
Newbie
 
Join Date: Oct 2007
Posts: 28
Rep Power: 0 Simplesouljah is on a distinguished road
Unhappy Re: Hey Pf

Quote:
Originally Posted by DaWei View Post
How so? We can see your statements, but you haven't explained how the charges are supposed to be calculated. Have you tested to see that your input is correct? (I can see you haven't tested the input for failure, which is a bad thing to skip.) Have you worked your formulae by hand to see if they are what you expect?

Again, you're being overly reticent with the information. I'm sure we'll get to the bottom of your problem, but it's easier when it isn't like pulling hen's teeth.

I'm sorry....here's what my programs is suppose to do:

A connection fee of $1.99 will be assessed for all
calls; the first three minutes will cost $2.00 per minute; after three
minutes, each additional minute will cost $0.45.
Write a program that prompts the user for the number of minutes the call
lasted and outputs the cost of the phone call.
Simplesouljah is offline   Reply With Quote
Old Oct 28th, 2007, 7:10 PM   #12
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: Hey Pf

Your charge for calls over three minutes should be connection fee + (3 * cost of minutes up to 3) + ((minutes - 3) * cost of minutes over 3). Working this out before hitting the keyboard is a good idea.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 28th, 2007, 7:10 PM   #13
Jabo
Not a user?
 
Join Date: Sep 2007
Posts: 255
Rep Power: 1 Jabo is on a distinguished road
Re: Hey Pf

Might we infer something about the teacher who gave this problem?
Jabo is offline   Reply With Quote
Old Oct 28th, 2007, 7:11 PM   #14
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: Hey Pf

You might, but I don't think that helps the OP solve this problem, or future problems.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 28th, 2007, 7:22 PM   #15
Simplesouljah
Newbie
 
Join Date: Oct 2007
Posts: 28
Rep Power: 0 Simplesouljah is on a distinguished road
Re: Hey Pf

I am still confused.....
Simplesouljah is offline   Reply With Quote
Old Oct 28th, 2007, 7:47 PM   #16
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: Hey Pf

And I read your mind as to what is confusing you, right?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 28th, 2007, 7:50 PM   #17
Simplesouljah
Newbie
 
Join Date: Oct 2007
Posts: 28
Rep Power: 0 Simplesouljah is on a distinguished road
Re: Hey Pf

Quote:
Originally Posted by DaWei View Post
And I read your mind as to what is confusing you, right?

yes
Simplesouljah is offline   Reply With Quote
Old Oct 28th, 2007, 9:19 PM   #18
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 824
Rep Power: 4 The Dark is on a distinguished road
Re: Hey Pf

This code:
    if (min  <= 3)  
       total = cf + (ftm * min);
       
    else (min > 3);
       total = cf + ftm + (min * adm);
You are missing an "if" after the else and you have a semi-colon after the (min > 3).
This is what the compiler interprets this as:
    if (min  <= 3)  
    {
       total = cf + (ftm * min);
    } 
    else
    {
      (min > 3);  // note - this does nothing.
    }
    total = cf + ftm + (min * adm);
So you are always calculating the total using the second method - does this match your results?

Edit: I only looked at the syntax, not the logic. See Dawei's posts as well.

Last edited by The Dark; Oct 28th, 2007 at 9:21 PM. Reason: Posted before noticing second page in thread :(
The Dark is offline   Reply With Quote
Old Nov 4th, 2007, 8:01 AM   #19
Simplesouljah
Newbie
 
Join Date: Oct 2007
Posts: 28
Rep Power: 0 Simplesouljah is on a distinguished road
Re: Hey Pf

I need 2 Write a program with a for or while loop that will calculate the sum of intergers between 1 & 500 that are evenly divisible by either 7 or 11. then calculate an print to the screen how many intergers there are between 1 & 500 that are evenly divisible by either 7 or 11 and calculate the average number from the sum divided by the count, format it with two numbers after the decimal point. The average should come out to be 251.45. I need any help i can get thank you.

this is what i have so far, not sure what I'm doing wrong.
int main()

{
    int i, sum, count;
    sum = 0;
    count = 0;
    float averege;
    
for (i = 1; i <= 500; i++)
{
    if (i % 7 == 0 || i % 11 == 0)
    sum = sum += i;
    count = count++;
    }
    
    cout << fixed << setprecision(2);

    cout << "The sum is " << sum << " and the averege is " << averege << endl;

    cout << "The total count is " << count << endl;

system("pause");

return 0;
}

Last edited by DaWei; Nov 4th, 2007 at 10:38 AM. Reason: Added code tags. That's twice.
Simplesouljah is offline   Reply With Quote
Old Nov 4th, 2007, 3:07 PM   #20
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 824
Rep Power: 4 The Dark is on a distinguished road
Re: Hey Pf

    sum = sum += i;
    count = count++;
The first line is adding i in twice.
The second line is adding 1 to count and then resetting it back to what it was.
You should just be using sum=sum+i and count++
The Dark is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hello PF maligree Community Introductions 1 Oct 7th, 2007 10:01 PM
Hey all eyeball_kid Community Introductions 3 Oct 3rd, 2007 2:00 PM
Hey Yall Kelvoron Community Introductions 4 Aug 19th, 2007 1:07 PM
Hey Hey Want2learn Community Introductions 2 Jul 8th, 2007 2:26 PM
Hey benders0 Community Introductions 3 Jun 23rd, 2007 3:29 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:43 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC