Introduced Java 10 in Java Technology Course.
Enjoying REPL with Java 10.
Introduced Java10 in the ongoing Java Technology Batch. Also playing with *.jsh files.
Sample Program ( piggybank.jsh )
import static javax.swing.JOptionPane.*;
import static java.lang.Integer.*;
var balance = 0;
var lt = 0;
void statement(){
showMessageDialog(null,"Balance = " + balance +
"\n"+
" Last Transaction = "+lt);
}
void deposit(int v){
balance = balance + v;
lt = v;
}
void withdraw(int v){
if(balance >= v){
balance = balance - v;
lt = -v;
}
else{
showMessageDialog(null,"Insufficient Balance");
}
}
statement();
var sr1 = showInputDialog("Enter amount to deposit");
var r1 = parseInt(sr1);
deposit(r1);
statement();
var r2 = parseInt(showInputDialog("Enter amount to deposit"));
deposit(r2);
statement();
withdraw(parseInt(showInputDialog("Enter amount to withdraw")));
statement();
copyright ©Rajesh Patkar, All rights reserved.
Comments