Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Dan Hardison
- // The second activity of a budget calculator designed to help people manage their finances.
- // CS 007
- // 09/16/2014
- import java.util.Scanner; // needed to get input from user
- public class P1A4_Hardison_3812280 {
- public static void main(String[] args) {
- String userName; // store & test variables. Int used for simple numbers, double used in case of dollar amounts or percentages.
- int hoursWorked; // store variable for later
- int othoursWorked; // store variable for later
- int rentDue; // store variable for later
- int foodBudget;
- int funBudget;
- double otwageEarned;
- double carBill;
- double wageEarned; // store variable for later
- double grossPay; // store total earnings for later
- double eBill; // double used for these variables because of possible decimals for percentages
- double sBill;
- double wBill;
- double gBill;
- System.out.println("Welcome to Dan's calculator"); // Introduction to program
- System.out.println("This program will assist you in calculating your budget!");
- System.out.println("Coded by Dan Hardison");
- System.out.println("---------------------");
- // Get Scanner set up & get information
- Scanner keyboard = new Scanner(System.in);
- // get information w/ scanner
- System.out.println("Please enter your own name");
- userName = keyboard.nextLine();
- System.out.println("How many hours do you work per week?");
- hoursWorked = keyboard.nextInt();
- System.out.println("How many overtime hours did you work?");
- othoursWorked = keyboard.nextInt();
- System.out.println("What is your current job's wage?");
- wageEarned = keyboard.nextDouble();
- System.out.println("What is your current job's overtime wage?");
- otwageEarned = keyboard.nextDouble();
- System.out.println("What percentage of your pay goes towards the electric bill?");
- eBill = keyboard.nextDouble();
- System.out.println("What percentage of your pay goes towards your water bill?");
- wBill = keyboard.nextDouble();
- System.out.println("What percentage of your bill goes towards your sewage bill?");
- sBill = keyboard.nextDouble();
- System.out.println("What percentage of your bill goes towards your gas bill?");
- gBill = keyboard.nextDouble();
- System.out.println("How much money do you want to spend on food?");
- foodBudget = keyboard.nextInt();
- System.out.println("How much money do you want to spend on entertainment?");
- funBudget = keyboard.nextInt();
- System.out.println("How much money do you have to spend on your car each month?");
- carBill = keyboard.nextDouble();
- grossPay = (wageEarned * hoursWorked)+(othoursWorked * otwageEarned);
- // print variables
- System.out.println("Hello, " + userName);
- System.out.println("You've worked this number of hours:" +hoursWorked);
- System.out.println("You've worked this number of over-time hours:" +othoursWorked);
- System.out.println("Your current wage is: " +wageEarned);
- System.out.println("You spend this percentage of your pay on electricity:" +eBill);
- System.out.println("You spend this percentage of your pay on water:" +wBill+ "%");
- System.out.println("You spend this percentage of your pay on sewage:" +sBill+ "%");
- System.out.println("You spend this percentage of your pay on gas:" +gBill+ "%");
- System.out.println("You want to spend this much money on food: $" +foodBudget);
- System.out.println("You want to spend this much money on entertainment: $" +funBudget);
- System.out.println("Now let Dan's Budget Calculator™ do the rest!");
- System.out.println("-----------------------------------------------");
- System.out.println( );
- // Doing the math for their gross income
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement