Jump to content

While Loop


AcEBALL23

Recommended Posts

Problem Description (Using “While” Loop Only)

 

 

Margaret has looked at the wind floating over the prairies for a long time. After these observations, she has created a formula that will describe the altitude of a weather balloon launched from her house. In particular, her equation predicts the altitude A (in metres above the ground) at hour t after launching her balloon is:

 

A=-6t^4 + ht^3 + 2t^2+ t

 

 

Where h is an integer value representing the humidity as a value between 0 and 100 inclusive? Margaret is curious at what the earliest hour is (if any) that her weather balloon will hit the ground after launch, so long as it is no more than the maximum time, M, that Margaret is willing to wait. You can assume that the weather balloon touches ground when A ≤ 0.

Margaret has looked at the wind floating over the prairies for a long time. After these observations, she has created a formula that will describe the altitude of a weather balloon launched from her house. In particular, her equation predicts the altitude A (in metres above the ground) at hour t after launching her balloon is:

 

Where h is an integer value representing the humidity as a value between 0 and 100 inclusive? Margaret is curious at what the earliest hour is (if any) that her weather balloon will hit the ground after launch, so long as it is no more than the maximum time, M, that Margaret is willing to wait. You can assume that the weather balloon touches ground when A ≤ 0.

In order to do this, your program should use the formula to calculate the altitude when

t = 1, t = 2, and so on, until the balloon touches the ground or t = M is reached.

 

Input Specification

The input is two non-negative integers: h, the humidity factor, followed by M, the maximum number of hours Margaret will wait for the weather balloon to return to ground. You can assume 0 ≤ h 100 and 0 < M < 240.

 

Output Specification

The output will be one of the following possibilities:

  • The balloon does not touch ground in the given time.
  • The balloon first touches ground at hour:

 

Where T is a positive integer value representing the earliest hour when the balloon has altitude less than or equal to zero.

 

Sample Input 1

30

10

 

Output for Sample Input 1

The balloon first touches ground at hour:

6

 

Sample Input 2

70

10

 

Output for Sample Input 2

The balloon does not touch ground in the given time.

 

 

Please help......

Link to comment
Share on other sites

Did you just make that topic up, or are you studying to be a social worker or something?

 

Nah, I'm almost finished with my crim law / crim justice split degree (thank god, 3 classes left), and the class is Victimology. I've sat on this essay for a month. now i gotta finish by monday =/

Edited by Mahngiel
Link to comment
Share on other sites

Thanks. It wasn't designed to be that way. After 8 years in the service, the only logical path I was suited for was law enforcement. By the time I finished my AA, I was convinced to interdiscipline-ize my degree in Crim Justice with Law. I have no idea what I'm going to do with it, but every federal position is available to me. I'll likely continue on and get a Juris Doctorate over the next few years.

 

That is, if I quit looking for excuses not to write this damned essay...

Link to comment
Share on other sites

Well, you committed two cardinal sins, AcEBALL23. First, this is the introductions forum - where there's a finger wagged at people who request help in here. There's actually a sticky for it. Secondly, you've failed to understand how this forum works. Basically, you tell us the problem (good job there) and you show us what you've tried in way of accomplishing said problem (you forgot that part).

 

If what you want is someone to do the work for you (much akin how I'm trying to pawn off my essay), you'll need to head over to the freelancer section where you can pay for this to be done.

Link to comment
Share on other sites

@Mahngiel: Good luck to you. If you're near a national border, I have a few relatives in Border Patrol and they love it (especially if you're bilingual). If not that, look into the Marshall's or the DA's squad, especially with a military background.

 

@AcEBALL23: What have you tried so far? You can't just copy and paste your homework and expect us to do it for you.

Link to comment
Share on other sites

Is Margaret really going to sit there for 10 DAYS (240 hours) waiting for the balloon to drop?

 

At 0% humidity, it will never leave the ground. At 100% humidity, it comes back in 17 hours. So Margaret is not going to starve to death after all.

 

 

20 lines of code, without comments or range checks :wacko: (I was bored --- and really worried about Margaret)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.