How To Make This Program

How To Make This Program

How To Make Java Calculation program
I want to Write a program in Java that calculates the sum of digits of an input number, prints it, then calculates the sum... output: 59 14 5 please help to make this program

View Answers

February 23, 2008 at 1:17 PM

import java.io.*;
import java.lang.*;
class stringnumber{
public static void main(String args[])throws IOException
{
int i,a=0,b,n=0,count=0;
String y,kh="0";

/* INPUT FROM THE KEYBOARD */

InputStreamReader obj=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(obj);
System.out.println("enter the number");
String ch=br.readLine();
a=ch.length();
for(count=0;count<=a;count++)
{
System.out.println(" the num entered is"+"\t"+"\t"+ ch);
System.out.println(" the string length is"+"\t"+ch.length());

/* SPERATING THE STRINGS .CONVERTING THE STRINGS TO INTEGERS.ADDITION OF

THE INTEGERS */

for(i=0;i<a;i++)
{
System.out.println(" the seperated strings

are"+"\t"+ch.charAt(i));
Character c = new Character(ch.charAt(i));
String s = c.toString();
b = Integer.parseInt(s);
n=n+b;
y=Integer.toString(n);
kh=y;
}
n=0;
System.out.println(" the sum is"+"\t"+kh);
ch=kh;
System.out.println(" new string is"+"\t"+ch);
a=kh.length();
System.out.println(" the new length now is "+"\t"+a);
}
System.out.println(" the remaining single digit number is "+"\t"+ch);
}
}

February 23, 2008 at 1:20 PM

if u don't understand any part , feel free to ask me
bye.









Related Tutorials/Questions & Answers:
how to make a program on array
how to make a program on array  When you make a program on array that the element will move downward and upward and when you input twice 0 then thats the time that it will not move. pls. give me a formula...tnx
How To Make This Program - Java Beginners
How To Make This Program  How To Make Java Calculation program I want to Write a program in Java that calculates the sum of digits of an input number, prints it, then calculates the sum... output: 59 14 5 please help to make
Advertisements
make a program
make a program  GoodEmployee is defined who has ALL the following properties: He should be married. He should have 2 or less than 2 children. His middle name should start with "k" but not end with "e" The last name should have
make this program in java
make this program in java  given array a[1,5,3,1].want to take value from array and print star(*) that number times columm wise . output shuld
how to make this pattern???
how to make this pattern???  how to make following pattern in javascript
how make ID - Ajax
how make ID  how make a ID in eyeball chat
How to make elements invisible ?
How to make elements invisible ?   How to make elements invisible
how to make exampage in jsp ?
how to make exampage in jsp ?  how to make a online exam page in jsp and servelet
How to make selectOneMenu scrollable
How to make selectOneMenu scrollable  how to make the selectOneMenu scrollable? I have around 20 values in drop down and i want the scrollable functionality after 5 values. Kindly reply as soon as possible. Thanks Shikha
how make excel
how make excel  how make excel spreadsheet IN JAVA. please send this code argently   Hello Friend, Try the following code: import java.io.*; import org.apache.poi.hssf.usermodel.HSSFSheet; import
how to make multiple rectangles
how to make multiple rectangles  I,m a beginner , m sorry if the question is really simple i have an array list.I want to print the contents...(JFrame.EXIT_ON_CLOSE); //Set JFrame size setSize(400,400); //Make JFrame
How to make directory in java
Description: This example demonstrate how to create a directory at specified...; } } Output: The result of this program is that it will make a dir at root directory of C drive
How to make first JSP page?
How to make first JSP page?  Hello, How I can make first JSP page? Thanks   HI, Beginner can learn JSP from writing the first Program... tutorial: How to make my first JSP page? Thanks
How to make a chain, make a chain, chain
How to make a chain       To learn how to design a chain in the photoshop has become so easy by this example, it has some important instruction to make it so follow
how to make paging with function ?
how to make paging with function ?  how to make paging with function ?   //this page is display.php <?php</p> $con=mysql_connect("localhost","root",""); if(!$con) { die("you can connect please check". mysql
how to make a field left justification
how to make a field left justification  how to make a field left justification.need code.thanks in advance
how to make a label left alignment?
how to make a label left alignment?  how to make a label left alignment
How to make first JSP page?
How to make first JSP page?  Hello, How I can make first JSP page? Thanks
How to make bubbles, make bubbles, bubbles
How to make bubbles      ... to make it easily to draw. New File: First take colored background file.ADS.... ADS_TO_REPLACE_3 Duplicate: Now make duplicate layer and press Ctr
how to make paging with class and ajax
how to make paging with class and ajax  paging with class and ajax
How to make a transparent text
How to make a transparent text Learn how to make a transparent... mask tool (T key) and make formatting as looking here. Write Text: Now write... text make copy (Ctr +C) and past (Ctr + V).ADS_TO_REPLACE_2 Drop Shadow: Go
How to make a bone, make a bone, a bone
How to make a bone       This example bone design example, It is very easy. If you are looking for, please follow now. New File: Create a new file.ADS_TO_REPLACE_1
How to make a new List in Java
How to make a new List in Java  Hi, I have to create list object in Java. How to make a new List in Java? Thanks (adsbygoogle = window.adsbygoogle || []).push({});   Hi, The easiest way is to use
how to make multiple choice questions
how to make multiple choice questions  I have to make a multiple choice choice using JSP/Servlets. I created a a session bean for the questions and answers. how to associate group of questions to a user? so each user will have
How to make halo effect
How to make halo effect       Now get ready to learn a simple way to make a halo effect on the picture, follow to make it. Take a picture: Capture any picture to give
New to JSP..need help to make & run a JSP program.
New to JSP..need help to make & run a JSP program.  Hi, I have installed Tomcat 5.5 on my system. Plz help me to make a simple JSP program. And also how to run it.ADS_TO_REPLACE_1   Hi Friend, Have you set
How to Make iPhone Window Application
How to Make iPhone Window Application  Hi, For Making iphone window application, what parameters i have to follow or provide example related to iphone window application. Thanks
How to make query and abstraction in Java
How to make query and abstraction in Java  Hi, I read the lessons you have in the sites. They are really useful. However, I could not write codes... PostgreSQL database, and I want to make a query and abstraction for a table. Could
How to make a button of different behaviour?
How to make a button of different behaviour?  Suppose In a jsp page I have a button SAVE with id="btnSave" value="SAVE" and a javascript function... ajaxInsertUpdateData(document.getElementByID("btnSave1").value,......); How to do
how to make combinations - Development process
how to make combinations  import java.util.*; interface Expression { public void interpret(ArrayList exp); } class OrExpression implements...; Hi friend, In your Program having many error and plz check it like
how to make employee i card
how to make employee i card  hello friends can anyone help me.. I have to make a project to make Identity card for employees...but i am facing problems with database and jsp connection ... also tell me how to retrive data
How to make a design document for exception handling in java
How to make a design document for exception handling in java  How to make a design document for exception handling
how can i make monthly register ?
how can i make monthly register ?  how can i make monthly register ? iam using jdeveloper
how to make paging with class and ajax
how to make paging with class and ajax  paging with class and ajax... displayLinks($show){ $this->show = $show; // How many links to show... displayLinks($show){ $this->show = $show; // How many links
How to make a Rectangle type pdf
How to make a Rectangle type pdf       In this program we are going to tell you how we can....  To make a program over this, firstly we need to import some packages
How to make a cross eye, make a cross eye, cross eye
How to make a cross eye       You can make a cross eye effect with any type of eye picture by using this example, It will surly help you to make this effect. Take a picture: Capture
How to make login form in Struts 2?
How to make login form in Struts 2?  Hi, How to make login form in Struts 2? Thanks   Hi, If you want to learn to make Login form in Struts then check following tutorial: How to create Login Form in Struts2? Thanks
How to make a 3D text, make a 3D text, a 3D text
How to make a 3D text      ... will guide you to make it. New File: Take a new file with any size as you like.ADS_TO_REPLACE_1 Text Formatting: Choose Horizontal type tool (T key) and make
How to make focus on an object, make focus on an object, focus on an object
How to make focus on an object       This example will teach you to make focus on the object so follow..._TO_REPLACE_1 Selection: Choose Polygonal lasso tool (L key) to make selection
How to make a cracked head, make a cracked head, a cracked head
How to make a cracked head     ..., I am going to teach you to make a cracked head. It is very easy to learn so..._TO_REPLACE_1 Past cracked picture: Now make copy of the cracked picture and take
How to make a diamond necklace, make a diamond necklace, diamond necklace
How to make a diamond necklace       This tutorial will give you instruction to make draw a diamond necklace, so follow all the steps to make similar. New file: First take a new
how to make traffic light code in java
how to make traffic light code in java  what is code of traffic light in java
how to Change column name and Make a unique column.
how to Change column name and Make a unique column.   how to Change column name and Make a unique column.   Hi, Following queries are used to rename a column and to make a column unique.ADS_TO_REPLACE_1 for rename
How to make a burning man, make a burning man, burning man
How to make a burning man      ...; Gaussian blur. ADS_TO_REPLACE_2 You will get it. Selection: Make selection... Paste into: Make copy any fire picture to paste in the man shape selection, go
How to make frame of the picture, make frame of the picture, frame of the picture
How to make frame of the picture   ..., I have mention here all the steps to make this effect. Take picture: First take a picture to framed.ADS_TO_REPLACE_1 Selection: Make selection
How to make a grass text, make a grass text, grass text
How to make a grass text       Come to know how to make a grass text effect. New File: Take...: Select Horizontal type tool (T key) and make formatting to write text
How to make an animation in the text, make an animation in the text, an animation in the text
How to make an animation in the text   ..., in this example we are going to make animation in the text that is so easy... tool (T key) then make formatting to write text.ADS_TO_REPLACE_1 Effect: Go
How to make a damaged road, make a damaged road, damaged road
How to make a damaged road      ... to this example to make it, it has some instruction to make this effect so follow them. Take..._TO_REPLACE_1 Selection: Make selection a area that you want to give damaged
How to make an angry face, make an angry face, angry face
How to make an angry face       We have this example to teach you a simple method to make an angry face. Picture: First take a picture to modify, I have taken here a cute baby.ADS
How to make a gel text, make a gel text, a gel text
How to make a gel text       This example will help you to draw a gel text effect, it is very easy to make. New File: Take a new file with any size as you want.ADS_TO_REPLACE_1

Ads