• 0

Need help with some pseudocode


Question

I need help with some homework from my intro to programming class. Here's what I have so far  

Design a flow chart or pseudocode for a program for Hunterville College that will display the projected tuition rate for the next 10 years. 
The current tuition is $15,000 per year and will increase by 4 percent next year, and every year after that the tuition increase is expected to be 0.5 more (thus 4%, then 4.5%, then 5%, etc).

The output should be:

 Year      Tuition

   1       15,600.00

   2       16,302.00

   3       17,117.10

   4       18,058.54

   5       19,142.05

   6       20,386.29

   7       21,813.33

   8       23,449.33

   9       25,325.27

   10      27,477.92
   
                 HERES WHAT I HAVE SO FAR 
//Lab 5 
//Show the increase in tuition for Hunterville College 
//It will increase by 4% the first year and an added 0.5% each following year 

Begin Main module 

Declare Integer original_tuition
Declare Integer year
Declare Real tuitionA-J

	Display "Year    Tuition" 

Set year = 0 
Set original_tuition = 6000
While year = 1 {
tuitionA = original_tuition + 0.04*original_tuition
Set mArray[1] = tuitionA   
	Display "1      ;tuitionA"tuitionA 
End While	

While year = 2
tuitionB = = tuitionA + 0.045tuitionA 
Set mArray[2] = tuitionB
	Display "2      ;tuirionB"tuitionB 

 

Now I could just continue it like this, but is there any way i can make it into a loop? I feel that would be more efficient. Thank you 

-crisP  

Link to comment
https://www.neowin.net/forum/topic/1275370-need-help-with-some-pseudocode/
Share on other sites

7 answers to this question

Recommended Posts

  • 0

http://codepen.io/mur/pen/9dfc971f15e9ef98a70bb7f970712417/left/

I ended up doing this, didn't really like the idea of "doing it for you" but it will give you a bit of a sense of how the information gets processed. I used a loop (naturally) as you mentioned because it was the best way to do it, you can modify all of the values at the top to get different outcomes as well.

  • 0
  On 15/10/2015 at 05:15, Mur said:

http://codepen.io/mur/pen/9dfc971f15e9ef98a70bb7f970712417/left/

I ended up doing this, didn't really like the idea of "doing it for you" but it will give you a bit of a sense of how the information gets processed. I used a loop (naturally) as you mentioned because it was the best way to do it, you can modify all of the values at the top to get different outcomes as well.

 

Holy overkill, Batman!

t = 15400

y = 1

i = 1.04

print y,  t

while (y < 10)

{

   i=i+.005

     t=t * i

    y=y+1

    print y,t

}

thats pseusdocode, the smallest sketch that communicates the algorithm

neowin scrolled the increase line far right so it wasn't in my window!

"

tuition increase is expected to be 0.5 more (thus 4%, then 4.5%, then 5%, etc).

"

now fixed lol

OP: download code that intrigues you from GitHub. and hit khan academy - there is no way a loop should be a puzzle to you - khan has a cool section where you can copy other peoples javascript mini-games and then hack on it - but read lots of other people's code

And maybe read my comments here:

www.neowin.net/forum/topic/1273312-learning-to-code-best-options-issues/

 

Edited by DevTech
off-by-one error lol
  • 0
  On 15/10/2015 at 15:36, DevTech said:

Holy overkill, Batman!

It took me under a minute to do that, and provides a working example in it's simplest form, not overkill at all. It's also only 23 lines factoring in everything involved.

  • 0
  On 15/10/2015 at 15:45, Mur said:

It took me under a minute to do that, and provides a working example in it's simplest form, not overkill at all. It's also only 23 lines factoring in everything involved.

 

yeah but it is real working code, not pseudo

i fear we both went way too far on a homework thingy

( i think i will decline from responding to these in the future, too much like eating candy!)

  • 0
  On 15/10/2015 at 15:49, DevTech said:

yeah but it is real working code, not pseudo

i fear we both went way too far on a homework thingy

I'm working towards a PhD so it's what I naturally do :/

That said, your method starts are 15,400 which I'm not sure why (considering year one is $15,600 based on the OP) there's also no factoring in of the initial 4% increase, you've just applied it yourself initially which in a real world application isn't necessarily wrong, but for the assignment isn't answer what is asked.

  • 0
  On 15/10/2015 at 15:56, Mur said:

I'm working towards a PhD so it's what I naturally do :/

That said, your method starts are 15,400 which I'm not sure why (considering year one is $15,600 based on the OP) there's also no factoring in of the initial 4% increase, you've just applied it yourself initially which in a real world application isn't necessarily wrong, but for the assignment isn't answer what is asked.

15400 should be 15600 - typo

since it was pseudo code which is more like a flowchart, i thought there would be more clarity to start at 15600

depends on one definition of pseudocode but for me it's "paper napkin sketch" and doesn't even have to be completely correct as long as it jumpstarts the code

what phd you doing? and what's your research topic gonna be :)

 

  • 0
  On 15/10/2015 at 16:22, DevTech said:

15400 should be 15600 - typo

since it was pseudo code which is more like a flowchart, i thought there would be more clarity to start at 15600

depends on one definition of pseudocode but for me it's "paper napkin sketch" and doesn't even have to be completely correct as long as it jumpstarts the code

what phd you doing? and what's your research topic gonna be :)

That's fair, I prepare pseudo code mentally all the time when not at my laptop or office desktop. But to me it would be to clearly define what the process would be and segment out all variables for potential future modifications - since nothing is usually ever safe to be set in stone, and naturally robust options are far better in forward thinking).

PhD is in Human-centered Design and Engineering and I haven't decided on a research topic, there's 3 I am currently battling myself on, one will be a research topic while the other two become elongated blog posts (if I ever have time to get my blog site done), but I haven't selected which one I like best yet.

This topic is now closed to further replies.
  • Posts

    • The first stars in the universe may have been much smaller than we thought, new research hints — possibly explaining why it's so hard to find evidence they ever existed. According to the new research, the earliest generation of stars had a difficult history. These stars came to be in a violent environment: inside a huge gas cloud whipping with supersonic-speed turbulence at velocities five times the speed of sound (as measured in Earth's atmosphere). A simulation underpinning the new research also showed gases clustering into lumps and bumps that appeared to herald a coming starbirth. The cloud broke apart, creating pieces from which clusters of stars seemed poised to emerge. One gas cloud eventually settled into the right conditions to form a star eight times the mass of our sun — much smaller than the 100-solar-mass behemoths researchers previously imagined in our early universe. "With the presence of supersonic turbulence, the cloud becomes fragmented into multiple smaller clumps, leading to the formation of several less massive stars instead," principal researcher Ke-Jung Chen, a research fellow at the Academia Sinica Institute of Astronomy and Astrophysics in Taiwan https://www.livescience.com/space/astronomy/scientists-may-finally-know-why-the-first-stars-in-the-universe-left-no-trace  
    • No, it's probably not the de-specialized edition, but Disney could surprise the 'Star Wars' faithful when the rerelease drops in theaters in 2027. It might not be the big anime-style birthday remake some "Star Wars" acolytes were hoping for, but "Star Wars: A New Hope" will be blasting back into movie theaters to celebrate its landmark 50th anniversary starting in April of 2027. The sprawling space opera is set to hit the silver screen again with a special limited-edition theatrical run beginning on April 30, 2027, and aptly running through the official Star Wars Day holiday on May the 4th. This will be the planet-wide event too, so international Star Wars fans won't miss out. There is a sliver of hope for purist fans that perhaps Disney might pull out an untouched archival print — the original version of the sci-fi sensation that first hit theaters on May 25, 1977 — but it's unlikely that Disney would risk upsetting creator George Lucas. Instead, we'd expect a freshened-up 1997 20th anniversary print to be the star attraction. https://www.space.com/entertainment/space-movies-shows/star-wars-a-new-hope-will-return-to-theaters-to-celebrate-its-50th-anniversary-but-disney-didnt-say-which-version  
    • Those are not rights. Those were special treatments that were taken away that non-trans whatever didn't get. They should be treated like every other person, not special. They can still go get their "trans-affirming" care, they just have to pay for it like everyone else.
    • Realistically how many difficult thinking request does the average person needs per week? The simplest 'nonthinking' model is way more powerful than anything we had 18 months ago. While the average person using these things for? I wonder how many games coding apps I've just thrown together for the sake of having fun or testing. I know I've done it. I think we've got to a stage where we just randomly asking ChatGPT anything even if we don't use 95% of what we ask it. These thinking instances do have a cost, environmentally as well as other resources. As we all know the limits will go up, but I don't think it's a bad start.
  • Recent Achievements

    • One Month Later
      Jaclidio hoy earned a badge
      One Month Later
    • Week One Done
      Yawdee earned a badge
      Week One Done
    • Week One Done
      eugwalker earned a badge
      Week One Done
    • First Post
      Ben Gross earned a badge
      First Post
    • One Month Later
      chiptuning earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      640
    2. 2
      +FloatingFatMan
      183
    3. 3
      ATLien_0
      146
    4. 4
      Xenon
      123
    5. 5
      wakjak
      107
  • Tell a friend

    Love Neowin? Tell a friend!