Donut
February 25th, 2009, 10:30 PM
the title is probably misleading, but it is java related.
im in computer programming at my school, we are working with java in JCreator. pretty simple stuff so far, declaring and defining variables, doing math, and spitting it all back as a string.... ok, brutally easy.
today in class we went over declaring variables as int, and modulus division. all very easy. i understand all of it, but what i DONT understand is the practical application to it. id show you guys a script, but i didnt have time to save the damn thing to my flashdrive in class today, so the file is sitting in a folder on the desktop at school.
basically, the teacher wants us to prompt the user for a number of seconds (like 284), do some math, then spit out the time in minute:second format. i can do that with basic division, but the teacher wants us to use modulus division and take advantage of the fact that int variables drop the decimal place with division.
my question is why would you use modulus to calculate time like that, and how? ill get the sample script we did in class saved to my flash drive tomorrow and post it
E: oh the assignments are posted on my school's website. here are the specifics:
Create a TimeConversion application that prompts the user for a time in minutes and then displays the time in hours and minutes. Be sure to consider times whether the number of minutes left over is less than 10. For example, 184 minutes in hour:minute format is 3:04 (Hint: use the modulus operator). The application output should look similar to:
Enter the time in minutes: 135 The time is: 2:15
apparently im supposed to calculate burger cost too, but it has nothing to do with the modulus stuff we learned today. goddamn this guy sucks with directions
E2: im not asking anybody to do my work, im just wondering how and why a person would use modulus to do something like this
E3: seeing a pattern here. all of the assignments are taking a number, splitting it into smaller groups (time: 60 seconds = 1 minute, little league baseball teams: 13 kids per team) and calculating the left overs. obviously the colon in the time readout is done using a string in a System.out.print thing.
E4: i totally didnt edit this like 8 times in the past 5 minutes :saddowns:
im in computer programming at my school, we are working with java in JCreator. pretty simple stuff so far, declaring and defining variables, doing math, and spitting it all back as a string.... ok, brutally easy.
today in class we went over declaring variables as int, and modulus division. all very easy. i understand all of it, but what i DONT understand is the practical application to it. id show you guys a script, but i didnt have time to save the damn thing to my flashdrive in class today, so the file is sitting in a folder on the desktop at school.
basically, the teacher wants us to prompt the user for a number of seconds (like 284), do some math, then spit out the time in minute:second format. i can do that with basic division, but the teacher wants us to use modulus division and take advantage of the fact that int variables drop the decimal place with division.
my question is why would you use modulus to calculate time like that, and how? ill get the sample script we did in class saved to my flash drive tomorrow and post it
E: oh the assignments are posted on my school's website. here are the specifics:
Create a TimeConversion application that prompts the user for a time in minutes and then displays the time in hours and minutes. Be sure to consider times whether the number of minutes left over is less than 10. For example, 184 minutes in hour:minute format is 3:04 (Hint: use the modulus operator). The application output should look similar to:
Enter the time in minutes: 135 The time is: 2:15
apparently im supposed to calculate burger cost too, but it has nothing to do with the modulus stuff we learned today. goddamn this guy sucks with directions
E2: im not asking anybody to do my work, im just wondering how and why a person would use modulus to do something like this
E3: seeing a pattern here. all of the assignments are taking a number, splitting it into smaller groups (time: 60 seconds = 1 minute, little league baseball teams: 13 kids per team) and calculating the left overs. obviously the colon in the time readout is done using a string in a System.out.print thing.
E4: i totally didnt edit this like 8 times in the past 5 minutes :saddowns: