I am ready to submit an assignment for my programming fundamentals class (intro class to Java 1) and the use of methods is extra credit for each assignment, so I have completed the assignment but was needing help converting the code to use methods. The instructor says no less than 6 methods should be used (which is where I get lost) and each calculation needs to be in its own method. Anyways, any some help would be appreciated... (the class uses only psudocode)
Question: Create the logic for a program that continuously prompts the user for a number of dollars until the user enters 0. Pass each entered amount to a conversion method that displays a breakdown of the passed amount into the fewest bills; in other words, the method calculates the number of 20s, 10s, 5s, and 1s needed.
My current (psudo)Code:
start
Declarations
num dollars
dollars = inputDollarAmt()
while dollars not equal to 0
dollarConversion(dollars)
dollars = inputDollarAmt()
endwhile
stop
num inputDollarAmt()
Declarations
num dollars
num QUIT = 0
output “Enter a dollar amount or ”, QUIT, “ to quit”
input dollars
return dollars
void dollarConversion(num dolls)
Declarations
num twenties
num tens
num fives
num ones
twenties = dolls / 20
dolls = dolls % 20
tens = dolls / 10
dolls = dolls % 10
fives = dolls / 5
dolls = dolls % 5
ones = dolls
output “You will need: ”, twenties, “ 20s, ”, tens, “ 10s, ”, fives, “ 5s, and ”, ones, “ 1s”
return
The problem with that is that unless you're using actual Office, you'll run into various weird compatibility issues. I'm not pointing fingers at who is responsible for "creating" them, nor am I saying there might not be issues with Office, but the fact remains there will be more of them with LibreOffice and the likes and often they'll just be borderline unsolvable. And it only takes so many of clients/users complaining to give up and just use actual Office. Been there, done that.
Until something doesn't just work in Windows. Especially driver wise where Linux usually just has driver support in the Kernel. I agree with you on gaming, it's still not there, but for multimedia, Linux has been a thing for years now. I've been using it on all my non-gaming systems and I'd never ever go back to Windows.
Question
ghostprodigy333
I am ready to submit an assignment for my programming fundamentals class (intro class to Java 1) and the use of methods is extra credit for each assignment, so I have completed the assignment but was needing help converting the code to use methods. The instructor says no less than 6 methods should be used (which is where I get lost) and each calculation needs to be in its own method. Anyways, any some help would be appreciated... (the class uses only psudocode)
Question: Create the logic for a program that continuously prompts the user for a number of dollars until the user enters 0. Pass each entered amount to a conversion method that displays a breakdown of the passed amount into the fewest bills; in other words, the method calculates the number of 20s, 10s, 5s, and 1s needed.
My current (psudo)Code:
Link to comment
https://www.neowin.net/forum/topic/1315002-converting-to-methods/Share on other sites
3 answers to this question
Recommended Posts