0

Hello!

I am totally stuck. My assignment says, "At one college, the tuition for a full-time student is $6,000 per semester. It has been announced that the tuition will increase by 2% each year for the next five years. Design a program with a loop that displays the projected semester tuition amount for the next five years."

Now, I am using flowgorithm for this, which is kinda like pseudocode and flowcharts together. So far I have:

Display "This program calculates the projected semester tuition for the next five years. "
Declare Real tuition

Set tuition = 6000.00
Declare Integer counter

Set counter = 1
Declare Real tuitionNew

For counter = 1 to 5
Set tuitionNew = tuition 1.02
Display "Year ", counter, "tuition will be ", tuitionNew
End For

For some reason, each year's tuition turns out to equal 6120, which is not what I want! Could someone please help me and explain what's going on?

Thank you!

3
Contributors
4
Replies
34
Views
10 Months
Discussion Span
Last Post by AssertNull
0

Year 0 tuition = 6000
Year 1 tuition = Year 0 tuition times 1.02
Year 2 tuition = Year 1 tuition times 1.02
Year 3 tuition = Year 2 tuition times 1.02
Year 4 tuition = Year 3 tuition times 1.02
Year 5 tuition = Year 4 tuition times 1.02

That's what you want. Here's what you have...

Year 0 tuition = 6000
Year 1 tuition = Year 0 tuition times 1.02
Year 2 tuition = Year 0 tuition times 1.02
Year 3 tuition = Year 0 tuition times 1.02
Year 4 tuition = Year 0 tuition times 1.02
Year 5 tuition = Year 0 tuition times 1.02

Your variable called tuition never changes. It is set as 6000 and remains 6000.

0

So what do I change (or add)? Must I declare more variables (year1, year2, etc...)?

0

Hello,

There is no need to declare new variables. From what I saw in your Pseudo Code. You forgot to increment your yearly tuition percentage. If the first year is 1.02 the second year should be 1.04 and so on.

Edited by Manny_2

0

Didn't see your response post. Sorry. Would have responded quicker. I changed your variable names slightly and added a new variable to hopefully make it a little more clear what the logic needs to be. I am unfamiliar with this software, so I don't know how to add comments. I'll use C++ style comments. Anything on a line after // is a comment. Anything between /* and */is a comment. Comments are ignored by the software and to be read by humans. Check your software and see if it allows comments and if so, how do you add them. Change the below or remove the comments so it works.

Display "This program calculates the projected semester tuition for the next five years. "
Declare Real tuitionInitial
Declare Real tuitionCurrentYear
Declare Real tuitionNextYear

Set tuitionInitial = 6000.00 // year 0 tuition is $6000
Set tuitionCurrentYear = tuitionInitial // we are in year 0.

Declare Integer counter

Set counter = 0

For counter = 0 to 5
Display "Year ", counter, " tuition is ", tuitionCurrentYear

Set tuitionNextYear = tuitionCurrentYear 1.02 // tuition for NEXT year is 1.02 times the tuition for THIS year
Set tuitionCurrentYear = tuitionNextYear // new year.  Make THIS year the CURRENT year
End For
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.