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

View Answers

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.









Related Tutorials/Questions & Answers:
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 ADS_TO_REPLACE_1 help me plz
ModuleNotFoundError: No module named 'total'
ModuleNotFoundError: No module named 'total'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'total' How to remove the ModuleNotFoundError: No module named 'total'
Advertisements
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
ModuleNotFoundError: No module named 'total-ordering'
ModuleNotFoundError: No module named 'total-ordering'  Hi, My... named 'total-ordering' How to remove the ModuleNotFoundError: No module named 'total-ordering' error? Thanks   Hi, In your python
id
id  how to find date of birth and gender in id in html with the help of javascript
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
What is total AWS EMR cluster price
What is total AWS EMR cluster price  Hi, I want to calculate the AWS... two operations: Get the total cost of an EMR workflow for a given period of days aws-emr-cost-calculator total --created_after=<YYYY-MM-DD> --created
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.ADS_TO_REPLACE_1 syntax disk_total_space() Function PHP
ModuleNotFoundError: No module named 'location-history-total'
ModuleNotFoundError: No module named 'location-history-total'  Hi...: No module named 'location-history-total' How to remove the ModuleNotFoundError: No module named 'location-history-total' error? Thanks   Hi
ModuleNotFoundError: No module named 'mantid-total-scattering'
ModuleNotFoundError: No module named 'mantid-total-scattering'  Hi...: No module named 'mantid-total-scattering' How to remove the ModuleNotFoundError: No module named 'mantid-total-scattering' error? Thanks   
ModuleNotFoundError: No module named 'mantid-total-scattering'
ModuleNotFoundError: No module named 'mantid-total-scattering'  Hi...: No module named 'mantid-total-scattering' How to remove the ModuleNotFoundError: No module named 'mantid-total-scattering' error? Thanks   
ModuleNotFoundError: No module named 'total-connect-client'
ModuleNotFoundError: No module named 'total-connect-client'  Hi...: No module named 'total-connect-client' How to remove the ModuleNotFoundError: No module named 'total-connect-client' error? Thanks   Hi
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 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,ADS_TO_REPLACE_1 we can find the total number of rows in a table using
Java file get total space
Java file get total space In this section, you will learn how to get the total...(); System.out.println("Total Space = " + totalSpace + " bytes"); } } You can find the total space of a disc or partition using the method
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
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
calculate total hours by start time and end time in javascript - Ajax
calculate total hours by start time and end time in javascript  hi, i... well. i want to display total hours by using start and end timepicker. pls clarify my doubts. how to calculate total hours by using start and end time field
ModuleNotFoundError: No module named 'odoo10-addon-account-invoice-check-total'
ModuleNotFoundError: No module named 'odoo10-addon-account-invoice-check-total...: ModuleNotFoundError: No module named 'odoo10-addon-account-invoice-check-total' How...-invoice-check-total' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo10-addon-account-invoice-check-total'
ModuleNotFoundError: No module named 'odoo10-addon-account-invoice-check-total...: ModuleNotFoundError: No module named 'odoo10-addon-account-invoice-check-total' How...-invoice-check-total' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo10-addon-website-sale-line-total'
ModuleNotFoundError: No module named 'odoo10-addon-website-sale-line-total...: ModuleNotFoundError: No module named 'odoo10-addon-website-sale-line-total' How...-total' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'odoo11-addon-account-invoice-check-total'
ModuleNotFoundError: No module named 'odoo11-addon-account-invoice-check-total...: ModuleNotFoundError: No module named 'odoo11-addon-account-invoice-check-total' How...-invoice-check-total' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo12-addon-account-invoice-check-total'
ModuleNotFoundError: No module named 'odoo12-addon-account-invoice-check-total...: ModuleNotFoundError: No module named 'odoo12-addon-account-invoice-check-total' How...-invoice-check-total' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo9-addon-account-invoice-check-total'
ModuleNotFoundError: No module named 'odoo9-addon-account-invoice-check-total...: ModuleNotFoundError: No module named 'odoo9-addon-account-invoice-check-total' How...-invoice-check-total' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'sp-ask-running-total-daily-report'
ModuleNotFoundError: No module named 'sp-ask-running-total-daily-report' ...: ModuleNotFoundError: No module named 'sp-ask-running-total-daily-report' How to remove the ModuleNotFoundError: No module named 'sp-ask-running-total-daily-report'
ModuleNotFoundError: No module named 'split-total-gst-inc-gst-free'
ModuleNotFoundError: No module named 'split-total-gst-inc-gst-free'  ...: No module named 'split-total-gst-inc-gst-free' How to remove the ModuleNotFoundError: No module named 'split-total-gst-inc-gst-free' error
Calculate total number of elements remaining in the buffer.
Calculate total number of elements remaining in the buffer. In this tutorial, we will discuss how to calculate total number of elements remaining in the buffer.  IntBuffer API: The java.nio.IntBuffer class extends
Total Quality Management
for your lapses. Total Quality Management (TQM) is a part of business management
What will be the total cost for Golden Triangle Package tour from Delhi
What will be the total cost for Golden Triangle Package tour from Delhi   Hi, Can anyone give me the idea about Golden Triangle Package tour cost from New Delhi? I want's to travel by car. Thanks
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
<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
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
ModuleNotFoundError: No module named 'id'
ModuleNotFoundError: No module named 'id'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'id' How to remove the ModuleNotFoundError: No module named 'id' error
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
total time calculator (starttime+endtime) in servlet USING DATABASE IN SQL2000 PLZ ANY ONE HELPME
total time calculator (starttime+endtime) in servlet USING DATABASE IN SQL2000 PLZ ANY ONE HELPME   <%-- Document : insertdate Created on : Jul 19, 2013, 3:48:28 PM Author : CG0T4908 --%> <

Ads