Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

need help in c++


  • Please log in to reply

#1
ghizlane

ghizlane

    New Member

  • Member
  • Pip
  • 6 posts
[attachment=6450:attachment][attachment=6451:attachment]
my program has to perform these sequences:

[b]1. Prompt the user for desired altitude and a number of steps
2. Cause the balloon to ascend to 1/3 of the specified alltitude, then
cruise for one-quarter of the time steps
3. Repeat step 2 twice more(ascend 1/3, cruise 1/4, ascend 1/3, cruise 1/4)
4. Descend halfway to the ground, cruise for the remaining time steps, and then descend back to the ground
5. After the first balloon flight, the program should ask the user if he would like to continue


I wrote this, but i'm not sure if it's correct[


#include <iostream.h>
#include "balloon.h"

// illustrates use of Balloon class
// balloon (guided by auto-pilot) ascends, cruises, descends

main()
{
Balloon Gina;
Balloon Tina;
int rise; // how high to fly (meters)
int duration; // how long to cruise (seconds)

cout << "How high (in meters) to rise: ";
cin >> rise;

cout << "How long (in seconds) to cruise: ";
cin >> duration;

Gina.Ascend(rise); // ascend to specified height
Gina.Cruise(duration); // cruise for specified time-steps
Gina.Descend(0); // come to earth

cout << "How high (in meters) to rise: ";
cin >> rise;

cout << "How long (in seconds) to cruise: ";
cin >> duration;

Tina.Ascend(rise*1/3);
Gina.Ascend(rise*2);
Tina.Cruise(duration*1/4);
Gina.Cruise(duration *2);
Tina.Descend(0);
Gina.Descend(0);

}
  • 0

Advertisements


#2
juber0

juber0

    Member

  • Member
  • PipPip
  • 56 posts
Ok, after looking on the net, I am unable to find any help. Please wait until someone comes and helps, while I look on the internet :tazz:

Edited by juber0, 08 February 2006 - 09:29 AM.

  • 0

#3
ghizlane

ghizlane

    New Member

  • Topic Starter
  • Member
  • Pip
  • 6 posts
Thanks for your quick reply, i still have more files to run with the program

balloon.h
randgen.h
randgen.cpp
balloon.cpp


But i couldn't attach them to my topic

where can i send them to you

Thank you in advance

Ghizlane
  • 0

#4
Hai Mac

Hai Mac

    Member

  • Member
  • PipPipPip
  • 260 posts
Well, then compile it in some free C compiler (e.g. Bloodshed Dev-cpp) and see if it works :tazz:. Looks ok so far to me.
  • 0

#5
ghizlane

ghizlane

    New Member

  • Topic Starter
  • Member
  • Pip
  • 6 posts
Thanks juber0 for your search, please if you find anything post it here so i can modify my program

Thanks to you too Hai Mac for your reply, but i need to be definite that my answer is correct, but i'm 70%

not sure

Ghizlane
  • 0

#6
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 875 posts
"But i couldn't attach them to my topic"

try attaching a zip file
  • 0

#7
ghizlane

ghizlane

    New Member

  • Topic Starter
  • Member
  • Pip
  • 6 posts
thank you for you help
i did it

ghizlane
  • 0

#8
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 875 posts
thank you for letting us know
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP