Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 10:04 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 2 posts ] 
Author Question
 Question subject: variabel diskon migh not have been initialized
PostPosted: Fri Oct 28, 2011 5:43 pm 

Code:
public static void main(String[] argsthrows IOException{
        
        
int nofaktur ;
        
int kodebrang ;
        
double jmltransaksi;
        
double hargabarang;
        
double totalharga;
        
double diskon ;
        
double totalbayar;
DataInputStream input = new DataInputStream(System.in);
System.out.print("input nofaktur ="); nofaktur=Integer.parseInt(input.readLine());
System.out.print("input kodebarang ="); kodebrang=Integer.parseInt(input.readLine());
System.out.print("jmltransaksi = "); jmltransaksi=Integer.parseInt(input.readLine());

if (
kodebrang == 1
{
    
hargabarang 500000;
}
else if (
kodebrang==2
{
    
hargabarang 100000;
}
else 
{
hargabarang 50000;
}

totalharga hargabarang jmltransaksi;{
    
if ((
kodebrang == 1)&&(jmltransaksi >= 10))
diskon =  (int) (100 totalharga);}
else if (((
kodebrang== 1)||(kodebrang== 2)&&(jmltransaksi >= 5)))
diskon =  (int) (100 totalharga);}

 
totalbayar=totalharga-diskon ;
    
System.out.print("hargabarang =");System.out.print(hargabarang);
System.out.print("totalharga =");System.out.print(totalharga);
System.out.print("diskon =");System.out.print(diskon);
System.out.print("totalbayar =");System.out.print(totalbayar);
    }
    }




help me please


TOP
  
Reply with quote  
 Question subject: Re: variabel diskon migh not have been initialized
PostPosted: Mon Nov 07, 2011 12:32 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
you have to give initial values for within function defined variables which are :
Code:

      int nofaktur 
=0;
        
int kodebrang=;
        
double jmltransaksi=0.0d;
        
double hargabarang=0.0d;
        
double totalharga=0.0d;
        
double diskon=0.0d ;
        
double totalbayar=0.0d;
 

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 2 posts ] 
Quick reply


  

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team