![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 | |
|
Newbie
Join Date: Oct 2007
Posts: 28
Rep Power: 0
![]() |
Quote:
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. |
|
|
|
|
|
|
#12 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#13 |
|
Not a user?
Join Date: Sep 2007
Posts: 255
Rep Power: 1
![]() |
Re: Hey Pf
Might we infer something about the teacher who gave this problem?
|
|
|
|
|
|
#14 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#15 |
|
Newbie
Join Date: Oct 2007
Posts: 28
Rep Power: 0
![]() |
Re: Hey Pf
I am still confused.....
|
|
|
|
|
|
#16 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#17 |
|
Newbie
Join Date: Oct 2007
Posts: 28
Rep Power: 0
![]() |
Re: Hey Pf
|
|
|
|
|
|
#18 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 824
Rep Power: 4
![]() |
Re: Hey Pf
This code:
if (min <= 3)
total = cf + (ftm * min);
else (min > 3);
total = cf + ftm + (min * adm);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);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 :( |
|
|
|
|
|
#19 |
|
Newbie
Join Date: Oct 2007
Posts: 28
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#20 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 824
Rep Power: 4
![]() |
Re: Hey Pf
sum = sum += i;
count = count++;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++ |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |