Home Answers Viewqa Java-Beginners How To Make This Program

 
 


Harish Lodhi
How To Make This Program
2 Answer(s)      5 years and 3 months ago
Posted in : Java Beginners

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 Pages:
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
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
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 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 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
make a prog for this query
make a prog for this query  write a program implementing interface... in uppercase so........ plz giude how to do this program it s urgent for me now n... for the program are 1) store the data in text file 2)display salary when emp id
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.   Hi Friend, Have you set the classpath? Anyways
How to make a file read-only in java
How to make a file read-only in java A read-only file is any file... program will make a the file read only To make file read only file.setReadOnly(); method is used. In the page you learned how to make a file read only
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 this pattern???
how to make this pattern???  how to make following pattern in javascript
How to Make a Pdf and inserting data
How to Make a Pdf and inserting data       In this tutorial you will learn how we can make... the jsp.  To make this program firstly we need to import java.io.* package
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
make setup
make setup  i've made jbuilder application how could make autorun or jar executable for this application? waiting your answers soon
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
Make Paragraph and Set Alignment
are going to explain how we can make paragraph and how we can gives various alignment. To make a paragraph we use Paragraph("Text"... Make Paragraph and Set Alignment     
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
Ant make directory with relative path
Ant make directory with relative path       This example illustrates how to make directory, how to compile java file and how to create jar file. This is a simple program
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 class and ajax
how to make paging with class and ajax  paging with class and ajax
How to make bubbles, make bubbles, bubbles
How to make bubbles      ... to make it easily to draw. New File: First take colored background file. Draw... Overlay, use same both settings as given below. Duplicate: Now make
How to make a transparent text
How to make a transparent text Learn how to make a transparent...) and make formatting as looking here. Write Text: Now write your text as you like. I have written here "Text". After writing text make copy (Ctr
Make A website
Make A website  How expensive(hire someone) or hard would it be to create a website like this? I want to build a website where people can be users of the website with a small profile. Their is a point system (kinda like money
formatting program
. This program should be an example of how Java lets you format numbers and strings... -justify them. Show how we can make a column of decimal numbers line up...formatting program  Hi I needs some help with this program
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
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. Rounded rectangle
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
program
program   An old-style movie theater has a simple profit program... $.50 per attendee. Develop the program calculateTotalProfit that consumes the number of attendees (of a show) and calculates how much income the show earns
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
Program
Program  Define an Abstract class DigitalCamera with instance variables like make, model, resolution, etc, and create() to set the details of camera. Use three sub classes for three different makes (eg. Canon, Olympus, Sony
program
program  how to improve programming skills plss tell some tips..i am understanding concepts but unable to write program so,pls give some guideness plsss
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
program
program  no i want a program that shows how merge sort algorithm works in graphical representations like numbers are taken in circles and computation... in rectangles or circles wat ever it may be. the theme of program is to show algorithm
Make Money
Make Money       Can I make money from my web site by writing articles? Yes, You can make money from your web site. We are providing free information
program
program  how to draw lines using JSP
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
program
program  Develop a servlet to count how many times the servelt is accessed
How to make a file read-only
Description: This example demonstrate how to create a file and how to revoke the write permission of the same file. The method createFile creates a file...; } } Output: Note : Execution of this program will create
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
Program
Program  hey please help me ... How can write multiple choice question paper using radio button.After submit calculate marks and display our marks... can any body help for me.using servlet,html   Here is a jsp test
How to Java Program
How to Java Program       If you are beginner in java , want to learn and make career in the Java... and lowercase letters.So,be make sure the Program code should be same typed in your Command
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 CRUD without using SQL Server? by just using your GUI? (CRUD = Creating, Register, Update, Delete)
How to make a CRUD without using SQL Server? by just using your GUI? (CRUD = Creating, Register, Update, Delete)  well I got a Program that can... a CRUD again without using SQL Server. how to make it? please help
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
HTML make a thumbnail
HTML make a thumbnail  How do I make a thumbnail for my image

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.