Hi i am totally a beginner and trying a simple input/output program for practice, the whole programs run in my Eclipse compiler but the result is something like
Enter maintenance expense : 87
Enter School fees: 67
Enter Utility Bills: 98
Enter Grocery expense : 88
Total expense : 88 ( here is the problem it give the last value i enter)
import java.util.Scanner;
public class budgetSystem {
Scanner userInput = new Scanner(System.in);
private static Scanner userInput2;
public static void main(String[] args){
int utilityBills = 0;
int maintainceExp = 0;
int schoolExp = 0;
int groceryExp = 0;
int totalExp = 0;
userInput2 = new Scanner(System.in);
System.out.println("Enter Maintaince Expance:");
utilityBills = userInput2.nextInt();
System.out.println("Enter School Fees:");
utilityBills = userInput2.nextInt();
System.out.println("Enter Utility Bills:");
utilityBills = userInput2.nextInt();
System.out.println("Enter Grocery Expance:");
utilityBills = userInput2.nextInt();
totalExp= utilityBills + maintainceExp + schoolExp + groceryExp;
System.out.println("Total Expance: " + totalExp);
}
} // END OF BUDGET SYSTEM