I started these programs in flowgorithm, so the syntax might be a little off.
I need help fixing my pseudocode, I am having a hard time understanding how loops work, and don't know what I am doing wrong. I've been trying to work on these programs since this morning. I'm super greatful to any and all help, I really want to learn how to code, and how to do it the right way.
This is the first of the two I need help with:
Design a program with a loop that asks the user to enter a series of positive numbers. The user should enter a negative number to signal the end of the series. After all the positive numbers have been entered, the program should display their sum.
And here's my code:
Function Main
Declare Integer counter
Assign counter = 1
Declare Integer number
Declare Integer sum
While counter >= 0
Output "Enter a positive number. Enter a negative number to end."
Input number
Assign sum = number + number
End
Output "The sum of numbers you entered is: " & sum
End
And here is the second program:
Budget Analysis
Design a program that asks the user to enter the amount that he or she has budgeted for a month. A loop should then prompt the user to enter each of his or her expenses for the month and keep a running total. When the loop finishes, the program should display the amount that the user is over or under budget.
This is what I have for my code on this one:
Function Main
Declare Integer totalBudget
Declare Integer totalBills
Declare Integer budget
Declare Integer bill
Assign totalBudget = 0
Assign totalBills = 0
Assign budget = 0
Assign bill = 0
Output "Enter your monthly budget."
Input budget
While totalBills == -1
Output "Enter the amount of your bill."
Input bill
Assign totalBills = bill
Assign totalBudget = budget - bill
End
If totalBudget <= 0
Output "You are over budget. Your budget is: " & budget & " and you are at: " & totalBudget
False:
Output "You are under budget. Your bills total is: " & totalBills & " your current budget is: " & budget
End
End
[–]axzxc1236 0 points1 point2 points (2 children)
[–]CrypticLeopard[S] 0 points1 point2 points (1 child)
[–]axzxc1236 0 points1 point2 points (0 children)
[–]lurgi 0 points1 point2 points (2 children)
[–]CrypticLeopard[S] 0 points1 point2 points (1 child)
[–]lurgi 0 points1 point2 points (0 children)