Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   Hey Pf (http://www.programmingforums.org/showthread.php?t=14217)

Simplesouljah Oct 23rd, 2007 11:51 AM

Hey Pf
 
I'm new this this site and need help writing a program...

I need to write a program that prompts the user for the number of minutes the call
lasted and outputs the cost of the phone call. Format your output with two
decimal places and a dollar sign in front

can someone help me?????

Infinite Recursion Oct 23rd, 2007 11:54 AM

Re: Hey Pf
 
Please tell me that you attempted this homework yourself first. Show us some code or ask specific questions?

The cost of the call should be defined at the start, then read in the number of minutes (user input), multiple that by the cost variable and then display the total cost.

lectricpharaoh Oct 23rd, 2007 12:09 PM

Re: Hey Pf
 
Quote:

Originally Posted by Simplesouljah
can someone help me?????

I'm sure someone can, but it's doubtful anyone will, given your post. First off, as IR points out, we don't do homework for people. We're willing to help, but you have to make an attempt first, and show that you've rubbed at least a couple of brain cells together. Second, you didn't mention a language, and we're not psychic.

DaWei Oct 23rd, 2007 12:14 PM

Re: Hey Pf
 
Have a look at the rules. Here's an excerpt:
Quote:

Don't be lazy when it comes to doing your own schoolwork. Do not post homework problems expecting a quick answer - doing so is an invitation to getting flamed. However, if you take the time to show effort and ask a specific question about your homework that is confusing you, we will be more than happy to help you learn. For easy readability, always wrap programming code within posts in [code] and [inlinecode] tags. If you don't do it, moderators will have to do it for you, and that leads to grumpy mods.
You also might want to read the "How to Post a Question" sticky at the top of the C++ forum. It's generic.

Welcome to the forum.

Simplesouljah Oct 25th, 2007 12:25 PM

Re: Hey Pf
 
my prgram is in C++ and I'm not asking for a quick answer. And yes I have attempted to write it. I'm stuck on the using the selection statement if or i could use switch.

Narue Oct 25th, 2007 12:30 PM

Re: Hey Pf
 
>And yes I have attempted to write it.
I see no code that proves you've made an attempt.

>I'm stuck on the using the selection statement if or i could use switch.
Just pick one. They're functionally identical.

Simplesouljah Oct 28th, 2007 3:32 PM

Re: Hey Pf
 
Quote:

Originally Posted by Narue (Post 135805)
>And yes I have attempted to write it.
I see no code that proves you've made an attempt.

>I'm stuck on the using the selection statement if or i could use switch.
Just pick one. They're functionally identical.

:

#include <iostream>
#include <iomanip>

using namespace std;

int main ()
{
    float min, cf, ftm, adm, total;
    cf = 1.99;
    ftm = 2.00;
    adm = 0.45;

// Have user to input an integer number of minutes they used to call Paris//

    cout << showpoint << setprecision(4);
   
    cout << "Please enter the number of minutes for your call to Paris: ";
    cin >> min;
    cout << endl;
             
    if (min  <= 3) 
      total = cf + (ftm * min);
     
    else (min > 3);
      total = cf + ftm + (min * adm);
   
    cout << "Your long distnace call cost $ " << total << endl;
    cout << endl;
    cout << "Thank you" << endl << endl;
    system ("pause");
    return 0;
}

this is what I have so far....not sure what I'm doing wrong...

DaWei Oct 28th, 2007 5:24 PM

Re: Hey Pf
 
If you were to tell us what errors you're getting, that imply that you're doing it wrong, we could zero in much faster. As it is, you're asking us to break out the crystal ball and read your mind. If you haven't read the "How to Post a Question" thread at the top of the C++ forum, please do so. Also, if you skipped by reading the rules, try that too.

While you're thinking about that, also think about testing your input operations (as in 'cin') for success. Read your documentation for the things you use.

Simplesouljah Oct 28th, 2007 6:49 PM

Re: Hey Pf
 
Quote:

Originally Posted by DaWei (Post 135966)
If you were to tell us what errors you're getting, that imply that you're doing it wrong, we could zero in much faster. As it is, you're asking us to break out the crystal ball and read your mind. If you haven't read the "How to Post a Question" thread at the top of the C++ forum, please do so. Also, if you skipped by reading the rules, try that too.

While you're thinking about that, also think about testing your input operations (as in 'cin') for success. Read your documentation for the things you use.


I'm not getting an error, it's not calculating right....

DaWei Oct 28th, 2007 7:48 PM

Re: Hey Pf
 
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.


All times are GMT -5. The time now is 3:26 AM.

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