Question: All programming languages have strict rules known as syntax. All programmers must follow them when writing a program. If the programmer writes code that violates
All programming languages have strict rules known as syntax. All programmers must follow them when writing a program. If the programmer writes code that violates these rules, a syntax error will result and the program cannot be compiled or executed. When this happens, the programmer has to locate the error and correct it
For this reason, programmers find it helpful to write their programs in pseudocode pronounced sue doe code before they write a program in the actual code of a programming language. The word pseudo means fake, so pseudocode is fake code. It is an informal language that has no syntax rules and is not meant to be compiled or executed. Instead, programmers use pseudocode to create models or mockups of programs program design Once a satisfactory design has been created with pseudocode, the pseudocode can be translated directly to actual code.
Here is an example of how you might write pseudocode for a pay calculating program:
Display Enter the number of hours the employee worked.
Input hours
Display Enter the employees hourly pay rate.
Input payRate
Set grossPay hours payRate
Display The employees gross pay is $ grossPay
Each statement in the pseudocode represents an operation that can be performed in any highlevel language.
Pseudocode Assignment
Converting a Math Formula to Programming Statement
Suppose you want to deposit a certain amount of money into a savings account and then leave it alone to draw interest for the next years. At the end of years you like to have $ in the account. How much do you need to deposit today to make that happen? You can use the following formula to find out:
PFrn
The terms in the formula are as follows:
P is the present value, or the amount that you need to deposit today
F is the future value that you want in the account F$
r is the annual interest rate
n is the number of years that you plan to let the money sit in the account
It would be nice to write a computer program to perform the calculation, because we can experiment with different values for the terms. Here is an algorithm we can use:
Get the desired future rate?
Get the annual rate?
Get the number of years the money will sit in the account
Calculate the amount of money that will need to deposit
Display the result of the calculation from Step
In Step through we will prompt the user to enter the specified values. We will store the desired value in a variable named futureValue, the annual interest rate variable named rate, and the number of years in a variable named years.
In Step we calculate the present value, which is the amount of money that we will have to deposit. We will convert the previously shown in the following pseudocode statement. This statement stores the result of the calculation in the presentValue variable.
presentValue futureValue rate years
In Step we display the value in the presentValue variable.
Assignment Instructions:
Write the pseudocode for this program below. You should have an approximately of lines of code.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
