switch statements for budget program
So I'm fairly new to java, and i've been watching tons of tut's lately and i wanted to actually sit down and see if i could write my own program without using a reference so i did...
the program i chose to make was just a very very simple budget program for myself. i added variables of all my bills like // cableBill = 150; so on and so forth. then i have the user input
the current date i.e. 1-30 and then i made a switch statement of my date variable, a very long one at that, that adds up my bills that i have left to pay for the rest of the month depending on what the date is.
so i made 30 different cases for every day of the month.
just for clarification if i input 1 it adds up all my bills for the month because i haven't payed any. if i input 15 it will add up bills i have to pay from the 16-30 therefore excluding 1-15
my question is, is there a better method to doing this rather than creating 30 cases of the switch statement for every day?
Re: switch statements for budget program
you could user s Scanner, ask for a date, then iterate through a foot loop using said inputted value.
e.g. - if user enters 12, for loop will fire 12 times adding up all the bills for those 12 days.