1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Norah need help, Question in C++ PlZZZ

  1. Apr 6, 2009 #1
    PLZZZZZ HELP ME
    I am crying I have a test
    but, I don't know how to solve this problems
    PLEASSSSSSSSE HELP


    Problem#1:

    Write user-defined function to take a depth (in kilometers) inside the earth as input data; compute and print the temperature at this depth in degree Celsius and degree Fahrenheit. Write main program to call this function.
    Relevant Formulas

    Celsius=10(depth)+20.

    Fahrenheit=1.8 (Celsius)+32.

    Problem#2:

    The Air Force has asked you to write a program to label supersonic aircraft as military or civilian. Your program is to be given the plane's observed speed in km/h and its estimated length in meters.

    For planes traveling in excess of 1100 km/h, you will label those longer than 52 meters "civilian" and shorter aircraft as "military". For planes traveling at slower speeds, you will issue an "aircraft type unknown" message.

    Problem#3:

    Consider the following list of monthly rainfall in a city in millimeters.

    Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
    11.5 10.6 9.8 3.7 8.5 14.0 18.5 22.4 27.6 12.5 12.0 13.8

    Use an array with above data. It is desired to determine the month in which maximum and minimum rainfall occurred. Also find the average monthly rainfall and its standard deviation. Instead of actual names you can just print the number of month ranging from 1-12. No user input is required.

    R is the average rainfall and ri are monthly rainfalls.


    Problem#4:

    Twenty-five numbers are entered from the keyboard into an 1-D array. Write a C++ program to find out how many of them are positive, how many are negative, how many are even and how many odd.

    Problem#5:

    Write a complete C++program that takes the length and width of a rectangular yard and the length and width of a rectangular house situated in the yard. Your program should calculate and display the time required to cut the grass at the rate of two squire feet a second.
     
    Last edited: Apr 6, 2009
  2. jcsd
  3. Apr 6, 2009 #2

    CompuChip

    User Avatar
    Science Advisor
    Homework Helper

    What have you tried already?

    Problem 1, for example, is very basic. If you have ever done anything in C++ at all, you must have some idea how to do it?

    [edit]There you go: someone even solved one for you. Just asking for answers isn't going to help you do your test though...[/edit]
     
  4. Apr 6, 2009 #3

    CRGreathouse

    User Avatar
    Science Advisor
    Homework Helper

    Many of us would love to help. But we need to see what you have before we can do anything! Where do you get stuck?
     
  5. Apr 6, 2009 #4
    I'm sorry my solutions were removed. It's sort of a shame, since I think what you really need are a few solid examples to work from. I guess I would recommend looking at some simple tutorials on Google for c++. For instance, here's a program that doesn't answer any of your questions, but contains all the ideas you'll need to solve a couple...

    Code (Text):

    #include <iostream>
    using namespace std;

    void getSpeedProc()
    {
       double time, mph, kph;

       cout << "Please enter the time, in hours, taken to travel 3mi = 5km:" << endl;
       cout << "   time = ";
       cin >> time;

       mph = 3.0 / time;
       kph = mph * (5.0 / 3.0); // to convert from kph to mph, multiply by 5/3

       cout << "The speed is:" << endl;
       cout << "   speed = " << mph << " miles per hour" << endl;
       cout << "   speed = " << kph << " kilometers per hour" << endl;
    }

    void isDuckProc()
    {
       double weight, quacks;

       cout << "Please enter how much it weighs, in pounds:" << endl;
       cout << "   weight = ";
       cin >> weight;

       cout << "Please enter how many times you heard it quack:" << endl;
       cout << "   quacks = ";
       cin >> quacks;

       if(weight > 25.0)
       {
          cout << "Cannot classify this animal..." << endl;
       }
       else
       {
          if(quacks > 5)
          {
             cout << "This must be a duck!" << endl;
          }
          else
          {
             cout << "This is a goose, or something..." << endl;
          }
       }
    }


    int main()
    {
       getSpeedProc(); // calculates speeds...

       isDuckProc(); // determines whether something is a duck...

       return 0;
    }

     
    Your guess is as good as mine as to which problems these can serve as models for. I'll get to the others later. Best of luck!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook