Jishnu 160 Posting Pro

oh no..i forgot to put the code tags..

here is my improved program..the thing in bold is the suggested correction.

import corejava.Console;
/****************************************************************
**cLASS bANKaCCOUNT REPRESENTING THE RUN-TIME MULTI-USER SYSTEM**
****************************************************************/
public class BankAccount
{
    /****************************
    **DATA OF bANKaCCOUNT CLASS**
    ****************************/
    private static final int MAXACC=10;
    private static int acc_logged_in;
    private static int no_acc_created;
    private static Account[] database;
    /*******************************
    **METHODS OF bANKaCCOUNT CLASS**
    *******************************/
    // initialisation block
    {
        acc_logged_in=-1;
        no_acc_created=0;
        database=new Account[MAXACC];
        [B]for(int i=0;i<MAXACC;i++)
            database[i]=new Account();
[/B]    }
    private static void createnew()
    {
        String str;
        no_acc_created++;
        acc_logged_in=no_acc_created;
        str=Console.readLine("\nEnter your name : ");
        database[acc_logged_in].SETname(str);
        database[acc_logged_in].SETbalance(Console.readInt("Enter your initial balance : "));          
        database[acc_logged_in].SETaccountid((int)(Math.random()*32000));                              
        System.out.println("Your account I.D. is " + database[acc_logged_in].GETaccountid());
        System.out.println("Account created successfully...\n\n");
    }
    private static void login()
    {
        int i,no;
        boolean found=false;
        no=Console.readInt("\nEnter your account I.D. : ");
        for(i=0;i<no_acc_created;i++)
        {
            if(no==database[i].GETaccountid())
            {
                acc_logged_in=i;
                found=true;
                break;
            }
        }
        if(found==true)
            System.out.println("Logged in successfully as " + database[acc_logged_in].GETname() + "...\n\n");
        else
            System.out.println("Error : The I.D. did not match with any of the accounts !\n\n");
    }
    private static void logoff()
    {
        if(acc_logged_in==-1)
        {
            System.out.println("\nNo account is currently logged in !\n\n");
        }
        else
        {
            acc_logged_in=-1;
            System.out.println("\nLogged off your account successfully...\n\n");
        }
    }
    private static int menu()
    {
        int choice;
        System.out.println("\n\t\tBANK-ACCOUNT");
        System.out.println("\t\t~~~~~~~~~~~~");
        System.out.println("");
        System.out.println("\t<1> Create new account");
        System.out.println("\t<2> Log in your account");
        System.out.println("\t<3> Log off your account");
        System.out.println("\t<4> View current status");
        System.out.println("\t<5> Deposit an amount");
        System.out.println("\t<6> Withdraw an amount");
        System.out.println("\t<7> Exit BankAccount.java");
        do
        {
            choice=Console.readInt("\n\t\tEnter your choice (1 to 7): ");
        }
            while(choice<1||choice >7);
        return choice;
    }
    public static void main(String[] args)
    {
        int choice;
        boolean …
Jishnu 160 Posting Pro

Hi,

I am trying out a bank account program using the corejava package.
I am getting a run-time eception when I create a new account & am unable to trace where the error is.

Plz help. I am giving the code below.


import corejava.Console;/******************************************************************cLASS bANKaCCOUNT REPRESENTING THE RUN-TIME MULTI-USER SYSTEM******************************************************************/public class BankAccount{ /**************************** **DATA OF bANKaCCOUNT CLASS** ****************************/ private static final int MAXACC=10; private static int acc_logged_in; private static int no_acc_created; private static Account[] database; /******************************* **METHODS OF bANKaCCOUNT CLASS** *******************************/ // initialisation block { acc_logged_in=-1; no_acc_created=0; database=new Account[MAXACC]; } private static void createnew() { String str; no_acc_created++; acc_logged_in=no_acc_created; str=Console.readLine("\nEnter your name : "); database[acc_logged_in].SETname(str); database[acc_logged_in].SETbalance(Console.readInt("Enter your initial balance : ")); database[acc_logged_in].SETaccountid((int)(Math.random()*32000)); System.out.println("Your account I.D. is " + database[acc_logged_in].GETaccountid()); System.out.println("Account created successfully...\n\n"); } private static void login() { int i,no; boolean found=false; no=Console.readInt("\nEnter your account I.D. : "); for(i=0;i<no_acc_created;i++) { if(no==database.GETaccountid()) { acc_logged_in=i; found=true; break; } } if(found==true) System.out.println("Logged in successfully as " + database[acc_logged_in].GETname() + "...\n\n"); else System.out.println("Error : The I.D. did not match with any of the accounts !\n\n"); } private static void logoff() { if(acc_logged_in==-1) { System.out.println("\nNo account is currently logged in !\n\n"); } else { acc_logged_in=-1; System.out.println("\nLogged off your account successfully...\n\n"); } } private static int menu() { int choice; System.out.println("\n\t\tBANK-ACCOUNT"); System.out.println("\t\t~~~~~~~~~~~~"); System.out.println(""); System.out.println("\t<1> Create new account"); System.out.println("\t<2> Log in your account"); System.out.println("\t<3> Log off your account"); System.out.println("\t<4> View current status"); System.out.println("\t<5> Deposit an amount"); System.out.println("\t<6> Withdraw an amount"); System.out.println("\t<7> Exit BankAccount.java"); do { choice=Console.readInt("\n\t\tEnter your choice (1 to 7): …

Jishnu 160 Posting Pro

The exception is encountered after I enter a name.

Exception in thread "main" java.lang.NullPointerException

Jishnu 160 Posting Pro

Hi,

I am trying out a bank account program using the corejava package.
I am getting a run-time eception when I create a new account & am unable to trace where the error is.

Plz help. I am giving the code below.

import corejava.Console;
/****************************************************************
**cLASS bANKaCCOUNT REPRESENTING THE RUN-TIME MULTI-USER SYSTEM**
****************************************************************/
public class BankAccount
{
    /****************************
    **DATA OF bANKaCCOUNT CLASS**
    ****************************/
    private static final int MAXACC=10;
    private static int acc_logged_in;
    private static int no_acc_created;
    private static Account[] database;
    /*******************************
    **METHODS OF bANKaCCOUNT CLASS**
    *******************************/
    // initialisation block
    {
        acc_logged_in=-1;
        no_acc_created=0;
        database=new Account[MAXACC];
    }
    private static void createnew()
    {
        String str;
        no_acc_created++;
        acc_logged_in=no_acc_created;
        str=Console.readLine("\nEnter your name : ");
        database[acc_logged_in].SETname(str);
        database[acc_logged_in].SETbalance(Console.readInt("Enter your initial balance : "));          
        database[acc_logged_in].SETaccountid((int)(Math.random()*32000));                              
        System.out.println("Your account I.D. is " + database[acc_logged_in].GETaccountid());
        System.out.println("Account created successfully...\n\n");
    }
    private static void login()
    {
        int i,no;
        boolean found=false;
        no=Console.readInt("\nEnter your account I.D. : ");
        for(i=0;i<no_acc_created;i++)
        {
            if(no==database[i].GETaccountid())
            {
                acc_logged_in=i;
                found=true;
                break;
            }
        }
        if(found==true)
            System.out.println("Logged in successfully as " + database[acc_logged_in].GETname() + "...\n\n");
        else
            System.out.println("Error : The I.D. did not match with any of the accounts !\n\n");
    }
    private static void logoff()
    {
        if(acc_logged_in==-1)
        {
            System.out.println("\nNo account is currently logged in !\n\n");
        }
        else
        {
            acc_logged_in=-1;
            System.out.println("\nLogged off your account successfully...\n\n");
        }
    }
    private static int menu()
    {
        int choice;
        System.out.println("\n\t\tBANK-ACCOUNT");
        System.out.println("\t\t~~~~~~~~~~~~");
        System.out.println("");
        System.out.println("\t<1> Create new account");
        System.out.println("\t<2> Log in your account");
        System.out.println("\t<3> Log off your account");
        System.out.println("\t<4> View current status");
        System.out.println("\t<5> Deposit an amount");
        System.out.println("\t<6> Withdraw an amount");
        System.out.println("\t<7> Exit BankAccount.java");
        do
        {
            choice=Console.readInt("\n\t\tEnter your choice …
Jishnu 160 Posting Pro

Hi every=one,

This is in continuation to my last post. Eve after initialising the 2d pointer a, as suggested, the same probllem as described earlier persists.

Plz help

-Jishnu.

Hello,

The code below calculates the determinant of the matrix. I know that the method of global 2-d pointers is a poor programming practice (so u don't need to reply saying that!!!), but it is a simple method for an amateur programmer. As the code didn't work, I set two watches,
(After giving the input as a 3x3 matrix with elements numbered from 1 to 9) one on e[k][l] & another on b[k1][l1]. To my surprise, b[k1][l1] got modified on its own inspite the fact that e[k][l] at k=1 and l=1 had the value of 5.

Somebody plz help me out.

-Jishnu.

Jishnu 160 Posting Pro

Hi everybody,

I'm new to Java language & was previously working with C++. I'm totally confused as to what is the mechanism of passing variables having

1) built-in datatypes
2) array datatypes
3) user-defined objects as datatypes

to any function. Is it pass by value or reference ? If arguments can be passed in one of the ways, what is the manner in which they can be passed by the other mechanism ? Do pointers or references exist in Java ?

-Jishnu

Jishnu 160 Posting Pro

you can use the sine series for calculation upto a certain accuracy and then plot the curve

HI All
How can we generate a sine wave without using the sin() function.

Thanks
pretu

Jishnu 160 Posting Pro

Hello,

The code below calculates the determinant of the matrix. I know that the method of global 2-d pointers is a poor programming practice (so u don't need to reply saying that!!!), but it is a simple method for an amateur programmer. As the code didn't work, I set two watches,
(After giving the input as a 3x3 matrix with elements numbered from 1 to 9) one on e[k][l] & another on b[k1][l1]. To my surprise, b[k1][l1] got modified on its own inspite the fact that e[k][l] at k=1 and l=1 had the value of 5.

Somebody plz help me out.

-Jishnu.

#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
void show(float **a,int n);
float det(float **b,int n);
void minor(float **a,int o,int i,int j);
void main()
{
clrscr();
int o,i,j;
float **a,ans;
cout<<"Enter The Order Of Matrix:";
cin>>o;
for(i=0;i<o;i++)
a[i]=new float[o];
for(i=0;i<o;i++)
for(j=0;j<o;j++)
cin>>a[i][j];
ans=det(a,o);
cout<<ans;
getch();
}
void show(float **a,int n)
{
cout<<"\n";
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{cout<<setw(8)<<a[i][j]<<" ";}
cout<<"\n\n";
}
}
float **b;
float det(float **c,int n)
{
float ans=0;
float *d;
d=new float[n];
for(int i=0;i<n;i++)
d[i]=c[0][i];
if(n>2)
{
for(int i=0;i<n;i++)
{
minor(c,n,0,i);
if(i%2==0)
ans+=d[i]*det(b,n-1);
else
ans-=d[i]*det(b,n-1); 
}
}
if(n==2)
{
return(c[0][0]*c[1][1]-c[0][1]*c[1][0]);
}
return ans;
}
void minor(float **e,int o,int i,int j)
{
int k1=0,l1;
for(int k=0;k<o;k++)
{
l1=0;
for(int l=0;l<o;l++)
{
if(k==i)
{k1--;break;}
if(l==j)
continue;
[B]b[k1][l1]=e[k][l];:-O [/B]
l1++;
}
k1++;
}
}
Jishnu 160 Posting Pro

I have jdk1.2 but found some files missing. So i requested a link. I DO know the difference betn the 2. I have worked earlier with compilers without ide and am comfortable with them.

>>>>>>>>NO PIRACY INTENDED<<<<<<<<<<<<<

Thanks to peter_budo.

Jishnu 160 Posting Pro

Hi everybody,

Would any-one send me java compiler at <email snipped>

Jishnu 160 Posting Pro

Hello every-one,

I am new to java. Can any-one suggest some basic-level yet solid book for transition from c++ to java ?

Jishnu 160 Posting Pro

what is the relevance of the above link ?

Jishnu 160 Posting Pro

Can ne-1 explain 2 me the output of the following code ?

(Mind well, it's completely legal C code !! ; n it actually won the International Obfuscated C Code Contest.)

#include<stdio.h>
main(t,_,a)
char *a;
{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a
)&&t == 2 ?_<13 ?main ( 2, _+1, "%s %d %d\n" ):9:16:t<0?t<-72?main(_,
t,"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+\
,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/\
+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){n\
l]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\
n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\
#'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/")
:t<-50?_==*a ?putchar(a[31]):main(-65,_,a+1):main((*a == '/')+t,_,a\
+1 ):0<t?main ( 2, 2 , "%s"):*a=='/'||main(0,main(-61,*a, "!ek;dc \
i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}

Jishnu 160 Posting Pro

Hello eveyone,

I am working on a program that uses the graphics.h library functions
and the 0x33 mouse interrupt. When I click at a particular place on the
screen, the graphics nearby the mouse are saved and displayed on the
new screen (that appears due to the mouse click) when the mouse
position is changed. The same happens when I drag the mouse from one point to another.

Can some-one suggest a possible solution ?

Jishnu 160 Posting Pro

I have seen that writing anything after the completion of any
pre-processor compiler directive does not affect either compilation or
running of the program.
i.e.
#include<conio.h> 123as!#@
#define M 100 *&^asdf
is perfectly valid.

How can such athing happen ?

Jishnu 160 Posting Pro

Using the Turbo C++ Project facility, I have linked some 5-6 files
which consist of function definitions with a file which contains the
definition of main(). main() uses the function definitions that are given
in the other files. There are a lot of variables which need to be
accessed by all the functions. So I have declared them to be global.

The file that contains the main() definition compiles successfully but on
linking it gives the error :

Linker Error :
Undefined symbol 'function_name' in module 'file_containing_main'.

On compiling the files that contain other function definitions, it gives an
error :

Error :
Undefined symbol 'global_variable'.

I had done the same thing with another project which did not involve
global variables & it had worked.

So what should I do now ?

Jishnu 160 Posting Pro

Does anybody here know how can i manage global data in multifile
C programs ?

Plz do reply.