+ 1

What is "Exception in thread "main" java.util.NoSuchElementException" meaning?

Hi, I write code below that solve problem in code coach very well, but when I run this code in other code editor will send message Exception in thread "main" java.util.NoSuchElementException What is "Exception in thread "main" java.util.NoSuchElementException" meaning? btw this is the code: import java.util.Scanner; class Main { public static void main(String[] args) { Scanner read = new Scanner(System.in); double saving = read.nextDouble(); double checking = read.nextDouble(); Account savingAcc = new SavingAcc(saving); Account checkingAcc = new CheckingAcc(checking); System.out.println(savingAcc.getIncome()); System.out.println(checkingAcc.getIncome()); } } class Account { private double amount; public Account(double amount) { this.amount = amount; } public double getAmount() { return amount; } public double getIncome() { return 0; } } class SavingAcc extends Account { public SavingAcc(double amount) { super(amount); } //Override the method for saving account public double getIncome() { return getAmount()+getAmount()*0.2; } } class CheckingAcc extends Account { public CheckingAcc(double amount) { super(amount); } //Override the method for checking account public double getIncome() { return getAmount()+getAmount()*0.2; } }

1st Apr 2022, 5:40 PM
Achmad Shobari Sapta Budi Lesmana
1 Answer
0
Mainly it requires two inputs but if you don't input a value, it raise such error.. How you are running? What inputs you gave?
1st Apr 2022, 6:23 PM
Jayakrishna 🇼🇳