Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args){
- Scanner scanner = new Scanner(System.in);
- int totalExpenses = 0;
- int expenses;
- int budget;
- System.out.println("Enter your budget");
- budget = scanner.nextInt();
- System.out.println("Enter your expenses");
- while ((expenses = scanner.nextInt()) != 0)
- {
- System.out.println("You entered $" + expenses);
- totalExpenses += expenses;
- }
- System.out.println("Your money at the end of the month: $" + (budget - totalExpenses));
- if (totalExpenses > budget)
- {
- System.out.println("You're over the budget");
- }
- else
- {
- System.out.println("You're under the budget");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement