# total id

michael wong
total id
2 Answer(s)      6 years and 9 months ago
Posted in : Java Beginners

how to print and total my id number ..for example if my id is 0123456789 the output will look like this :

0123456789

0+1+2+3+4+5+6+7+8+9=45

help me plz

November 24, 2010 at 5:06 PM

Hi Friend,

Try the following code:

```import java.util.*;
public class IDNumber{
public static String removeCharAt(String s, int pos) {
StringBuffer buf = new StringBuffer( s.length() - 1 );
buf.append( s.substring(0,pos) ).append( s.substring(pos+1) );
return buf.toString();
}
public static void main(String[] args){
Scanner input = new Scanner(System.in);
StringBuffer buffer=new StringBuffer();
System.out.print("Enter Number:");
String st = input.nextLine();
String [] arr = new String[st.length()];
int sum = 0;
for (int i = 0; i < st.length(); i++){
arr[i] = st.substring(i,i+1);
buffer.append(arr[i]);
buffer.append("+");
sum = sum + Integer.parseInt(arr[i]);
}
int len=buffer.length();
System.out.println(len);
String result=removeCharAt(buffer.toString(),19);
System.out.print(result+"="+sum);
}
}
```

Thanks

November 24, 2010 at 11:00 PM

Hi, can you recommend a simple one using int array ? Because i cant understand the previous 1.Sorry and thanks a lot.

total id
total id  how to print and total my id number ..for example if my id is 0123456789 the output will look like this : 0123456789 0+1+2+3+4+5+6+7+8+9=45 help me plz
id
id  how to find date of birth and gender in id in html with the help of javascript
Total Hours Calculation.
Total Hours Calculation.   Hi,How to calculate the total hours by startime and endtime.not railway time just only normal time.please help. Thanks
program to print total marks
program to print total marks  program to input total marks out of 600 marks as an argument and print the stream allotted using the following criteria 401 & above - PCM 301-400 - ZBC 201-300- Commerce 101-200 - Arts
Total summay from a sale table
Total summay from a sale table  Total summay from a sale table
Session ID
Session ID  How can I change the session ID of the page?   ...' session ID values because it is very likely to result in the loss of the session or with people acquiring other users' data. The session ID value should be managed
Java program to generate the total count
Java program to generate the total count  I need a java program which would take a text file as an input and scans through it to generate the output. For Ex. : If the text file contains the following information: There is/are 3
<form id=
form id  sir, <form id="reg1" action="../UploadingCtrl" method="post" enctype="multipart/form-data" name="form1"> this action page can't get String tp = request.getParameter("indegrates"). i wrote article upload
<form id=
form id  sir, <form id="reg1" action="../UploadingCtrl" method="post" enctype="multipart/form-data" name="form1"> this action page can't get String tp = request.getParameter("indegrates"). i wrote article upload
id creation
id creation  CREATE TABLE mohan2 ( sno bigint(20) NOT NULL AUTO_INCREMENT, name varchar(30) NOT NULL, sal int(30) NOT NULL, eid varchar(30) NOT NULL, PRIMARY KEY (sno,eid) ) import java.sql.*; import
id generation
id generation  CREATE TABLE `mohan2` ( `sno` bigint(20) NOT NULL... to employee id automatically generate please try this code, useful for u thanks ...");%> any body want to employee id automatically generate please try
Find total disk space in PHP, php disk_total_space, disk_total_space
Learn How to Get the total disk space in PHP Program. In this PHP Tutorial example we will use the disk_total_space() function in our PHP code to find the total disk space. syntax disk_total_space() Function PHP disk_total_space
java total lost data in hard drive
java total lost data in hard drive  please help me, i need java source code about total lost data in hard drive. how to find the total deleted data ih hard drive using java programming... this my project...pls help me
Write a query to find the total number of rows in a table
Write a query to find the total number of rows in a table  Write a query to find the total number of rows in a table?   Hi, Here is the answer, we can find the total number of rows in a table using following query
java total lost data in hard drive
java total lost data in hard drive  please help me, i need java source code about total lost data in hard drive. how to find the total deleted data ih hard drive using java programming... this my project...pls help me
java total lost data in hard drive
java total lost data in hard drive  please help me, i need java source code about total lost data in hard drive. how to find the total deleted data ih hard drive using java programming... this my project...pls help me
JAVA TOTAL LOST DATA IN HARD DRIVE
JAVA TOTAL LOST DATA IN HARD DRIVE  please help me, i need java source code about total lost data in hard drive. how to find the total deleted data ih hard drive using java programming... this my project...pls help me
Java file get total space
Java file get total space In this section, you will learn how to get the total...("C:"); long totalSpace = file.getTotalSpace(); System.out.println("Total Space = " + totalSpace + " bytes"); } } You can find the total space
Modify the sales tax program to accept an arbitrary number of prices, total them, calculate the sales tax and print the total amount.
Modify the sales tax program to accept an arbitrary number of prices, total them, calculate the sales tax and print the total amount.  Modify the sales tax program to accept an arbitrary number of prices, total them, calculate
Java Applet - Adding a Button to Decrease a Total
); } public void paint(Graphics g) { g.drawString("Total: " + gettestone..., it will display a button in a frame, that when clicked on will increase a total. Basically it will count the total number of times you click the button. What I need
Display total disk drive capacity
Description: This example will demonstrate how to get the total disk space... This method gets the total disk capacity in the bytes. Code... of this example depends upon number of drive you have and the total disk capacity
php maintain session id
php maintain session id   How to maintain session ID for a user in PHP
Hibernate criteria by id.
Hibernate criteria by id.  How to display record by using criteria by id in Hibernate
How to write a program count total prices
How to write a program count total prices  Hi. all I've got a assignment to write a program that count total prices of 8 costumers. class PriceCalculator{ public void method(double quantity) { double result
How to write a program count total prices
How to write a program count total prices  Hi. all I've got a assignment to write a program that count total prices of 8 costumers. First class... stuck in count total prices of 8 costumers like in this picture ![alt text][1
Tutorial for total beginner in Java
Tutorial for total beginner in Java - Explains the Basics of Java programming language. This is a video tutorial for total beginner in Java. In this video... language. This video is for total beginner in Java which will teach how to create
how make ID - Ajax
how make ID  how make a ID in eyeball chat
How to get Button Id ?
How to get Button Id ?  How to get Button ID instead of its value in Servlet. (I am not using jsp right now
ID number program
ID number program  hi can anyone help me with the following program. a program that can determine a person,s date of birth, age, gender and citizenship by just entering the id number. thanks in advance
id sender uibutton
id sender uibutton  Hi, I want to find which button is clicked based on the id sender when UIButton is clicked. thanks   HI, Here is the code example: UIButton* myButton = (UIButton*)sender; NSLog(@"Button tag
How to print UIButton id
How to print UIButton id  How to get the id of the button in the IOS application? Thanks   Hi, You can use the following code: - (IBAction)btnClicked:(id)sender { UIButton *button = (UIButton *)sender; int