Advertisement
grodek118

Budget Analysis

Nov 30th, 2022
957
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 1 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args){
  8.        
  9.        Scanner scanner = new Scanner(System.in);
  10.  
  11.        int totalExpenses = 0;
  12.        int expenses;
  13.        int budget;
  14.  
  15.         System.out.println("Enter your budget");
  16.         budget = scanner.nextInt();
  17.         System.out.println("Enter your expenses");
  18.  
  19.        while ((expenses = scanner.nextInt()) != 0)
  20.        {
  21.            System.out.println("You entered $" + expenses);
  22.            totalExpenses += expenses;
  23.        }
  24.         System.out.println("Your money at the end of the month: $" + (budget - totalExpenses));
  25.  
  26.        if (totalExpenses > budget)
  27.        {
  28.            System.out.println("You're over the budget");
  29.        }
  30.        else
  31.        {
  32.            System.out.println("You're under the budget");
  33.        }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement