Free Essay

Pt1420 Introduction to Programming Lab03

In:

Submitted By barakuda318
Words 275
Pages 2
Variable Name | Problem(Yes or No) | If Yes, What is wrong? | Declare Real creditsTaken | NO | | Declare Int creditsLeft | YES | INT can only hold whole numbers, cant account for half credits. | Declare Real studentName | Yes | Needs to be string not Real. Real is for numbers | Constant Real creditsNeeded = 90 | No | |
Step 1

Step 2
What is wrong with the following calculation?
Set creditsLeft = creditsTaken – creditsNeeded
The calculation is backwards, if left as is it would read a negative number. It should be
Set creditLeft = creditsNeeded – creditsTaken.

Step 3
Display “The student’s name is”, studentName
The student’s name is Nolan Owens

Step 4
Display “The Network Systems Administration degree is awarded after 90 credits and”, studentName, “has”, creditsLeft, “left to take before graduation.”
The Network System Administration degree is awarded after 90 credits and Nolan Owens has 70 left to take before graduation.

Step 5 1. //Provide documentation on line 2 of what this program does 2. //This program shows how many credits a student needs to graduate from Network System Administration. 3. //Declare variables on line 4, 5, 6, and 7 4. Declare Real creditsTaken 5. Declare Real creditsLeft 6. Declare String studentName 7. Declare Constant Integer creditsNeeded = 90 8. //Ask for user input of studentName and creditsTaken on line 9-12 9. Display “What is the student’s name?” 10. Input studentName 11. Display “How many credits have they taken?” 12. Input creditsTaken 13. //Calculate remaning credits on line 14 14. Set creditsLeft = creditsNeeded – creditsTaken 15. //Display student name and credits left on line 16 and 17 16. Display “The student’s name is”, studentName, 17. Display “They have”, creditsLeft, “credits left until graduation.”

Lab 3.2

Similar Documents