Like Tree2Likes
  • 2 Post By stahta01

Please Help

This is a discussion on Please Help within the C++ Programming forums, part of the General Programming Boards category; I have been presented with the following practice question on a c++ course I'm taking. I have no access to ...

  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
    5,833
    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%.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    2,372
    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.
    Elkvis and manasij7479 like this.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21