Thread: Please Help

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    1

    Lightbulb Please Help

    I have been presented with the following practice question on a c++ course I'm taking. I have no access to the teacher so I do not know who to turn to

    The exercise says:

    2.7: Ocean Levels

    Assuming the ocean’s level is currently rising at about 1.5 millimeters per year, write a program that displays

    The number of millimeters higher than the current level that the ocean’s level will be in 5 years,
    The number of millimeters higher than the current level that the ocean’s level will be in 7 years,
    The number of millimeters higher than the current level that the ocean’s level will be in 10 years,

    Output labels: Each value should be on a line by itself, preceded by the a label of the form:
    In X years the ocean's level be higher by Y millimeters.
    where X is the number of years (5, 7 or 10) and Y is the value you calculate.


    ----------------------------------------------------------------------------------------------


    When I submit my code to the computer course software it gives me a logical error. The program runs fine when I execute but obviously its not the right answer. Is there something I'm missing as far as the math formula goes? Please help
    Here is the code I have so far:

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        double fiveYears, sevenYears, tenYears;
        
        fiveYears = 5 * 1.5; 
        sevenYears = 7 * 1.5; 
        tenYears = 10 * 1.5; 
        
    
        cout << "In 5 years the ocean's level be higher by " << fiveYears << " millimeters." << endl;
        cout << "In 7 years the ocean's level be higher by " << sevenYears << " millimeters." << endl;
        cout << "In 10 years the ocean's level be higher by " << tenYears << " millimeters." << endl;
        
        system("PAUSE");
        return 0;
    }

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    You might want to interpret the "logical error" reported by the "computer course software".

    That will presumably provide you with useful information .... which forum members here do not have access to, so cannot advise you about.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Did the directions tell you to have a this statement in it?

    Code:
    system("PAUSE");
    If not, remove it.
    If yes, I suggest you look for another school.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed