• 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

    • Windows 12 perhaps would have codename Midnight of the company profits 😂 This system and it's update program gets more ridiculous with every new version
    • yet there are still dumb people decisions which takes the bait and go just where Microsoft guides them. left right left right just as a water particle in a microwave
    • Free Download Manager 6.29.0.6379 by Razvan Serea Free Download Manager is a powerful, easy-to-use and absolutely free download accelerator and manager. FDM accelerates downloads by splitting files into sections and then downloading them simultaneously. As a result download speed increases up to 600%, or even more! FDM can also resume broken downloads so you needn`t start downloading from the beginning after casual interruption. FDM lets you download files and whole web sites from any remote server via HTTP, HTTPS and FTP. You can also download files using BitTorrent protocol. In addition, Free Download Manager allows you to: adjust traffic usage; to organize and schedule downloads; download video from video sites; download whole web sites with HTML Spider; operate the program remotely, via the internet, and more! Free Download Manager is compatible with the most popular browsers Google Chrome, Firefox, Microsoft Edge, Internet Explorer and Safari. Free Download Manager 6.29.0.6379 changelog: Improved new desktop UI style. Improved add-ons support. Libtorrent updated to 2.0.11. Fixed: various bugs (including ones in the classic UI style). Download: Free Download Manager (64-bit) | 45.8 MB (Freeware) Links: Home Page | Linux, Mac, Android | MS Store | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Would like nice for a Steam Deck, but I don't think I would like this on a PC.
    • Zen Browser 1.14.7b is out.
  • Recent Achievements

    • Week One Done
      hhgygy earned a badge
      Week One Done
    • One Month Later
      hhgygy earned a badge
      One Month Later
    • One Year In
      NIKI77 earned a badge
      One Year In
    • Week One Done
      artistro08 earned a badge
      Week One Done
    • Dedicated
      Balaji Kumar earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      636
    2. 2
      ATLien_0
      237
    3. 3
      Xenon
      166
    4. 4
      neufuse
      143
    5. 5
      +FloatingFatMan
      123
  • Tell a friend

    Love Neowin? Tell a friend!