Results 1 to 2 of 2
  1. #1
    iDynasty is offline Member
    Join Date
    May 2013
    Rep Power

    Default 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?

  2. #2
    monkeyjr97 is offline Senior Member
    Join Date
    Nov 2012
    Rep Power

    Default 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.

Similar Threads

  1. Trying to display switch statements
    By CupONoodles in forum New To Java
    Replies: 1
    Last Post: 03-20-2012, 05:22 AM
  2. Replies: 9
    Last Post: 01-31-2012, 02:48 PM
  3. switch statements & conditionals
    By linkxs in forum New To Java
    Replies: 7
    Last Post: 09-25-2011, 06:17 AM
  4. switch statements
    By jim01 in forum New To Java
    Replies: 7
    Last Post: 04-10-2011, 10:52 PM
  5. Using a switch/case with my if statements
    By coding in forum New To Java
    Replies: 2
    Last Post: 03-07-2011, 08:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts