qw

February 25, 2010 at 6:20 am Leave a comment

public class aaa {

public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println(“Masukkan angka 1 :”);
String bil1 = input.nextLine();
System.out.println(“Masukkan angka 2 :”);
String bil2 = input.nextLine();

int a = bil1.length();
int b = bil2.length();
int digit[] = new int[bil1.length()];
int carrie = 0;
int x;
for (x = a – 1; x >= 0; x–) {
digit[x] = (Integer.parseInt(“” + bil1.charAt(x)) + Integer.parseInt(“” + bil2.charAt(x)) + carrie) % 10;
carrie = (Integer.parseInt(“” + bil1.charAt(x)) + Integer.parseInt(“” + bil2.charAt(x)) + carrie) / 10;
}
if (carrie != 0) {
System.out.print(+carrie);
}
for (int i = 0; i < a; i++) {
System.out.print("" + digit[i]);

}
}
}

Advertisement

Entry filed under: Uncategorized. Tags: .

#wujud peduli google terhadap lingkungan Welcome to my life

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Pages

Calendar

February 2010
M T W T F S S
« Dec   Mar »
1234567
891011121314
15161718192021
22232425262728

jumlah pengunjung

Blog Stats

  • 3,907 hits

Follow

Get every new post delivered to your Inbox.