3 Java Programs for Beginners

Ads
 

3 Java Programs for Beginners

Write a program that prompts the user for 2 different integers, then prints out the numbers between the 2 integers (inclusive) and their squares and the sum of their squares.

Write a program that reads a string from a user and then prints it out one character at a time.

Write a program that will print the complete multiplication chart. Bonus for printing it out to a file (in the form of a chart).

Either of them will be help full. Thanks for any help in advance.

View Answers

April 25, 2012 at 1:01 PM

import java.util.*;

class NumberExample1 
{
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.print("Enter Number1: ");
        int num1=input.nextInt();

        System.out.print("Enter Number2: ");
        int num2=input.nextInt();
        int sum=0;
        System.out.println("Number Square");
        for(int i=num1+1;i<num2;i++){
        System.out.println(i+"\t"+(i*i));
        sum+=(i*i);
        }
        System.out.println("Sum of squares: "+sum);

    }
}

April 25, 2012 at 1:11 PM

import java.util.*;
class CharacterArray 
{
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.print("Enter String: ");
        String st=input.nextLine();
        System.out.println("Characters of string: ");
        char ch[]=st.toCharArray();
        for(int i=0;i<ch.length;i++){
            System.out.println(ch[i]);
        }
    }
}

April 25, 2012 at 1:17 PM

import java.io.*;

public class MultiplicationTable{
public static void main(String[] args) {
    try{
BufferedWriter bw=new BufferedWriter(new FileWriter("c:/table.txt",true));
int[][] array = new int[11][11];
for (int i=1; i<array.length; i++) {
for (int j=1; j<array[i].length; j++) {
array[i][j] = i*j;
System.out.print(" " + array[i][j]);
bw.write(" "+Integer.toString(array[i][j]));
}
System.out.println();
bw.newLine();
}
bw.close();
    }
    catch(Exception e){}
}
}

Ads









Related Tutorials/Questions & Answers:
3 Java Programs for Beginners
3 Java Programs for Beginners  Write a program that prompts the user for 2 different integers, then prints out the numbers between the 2 integers (inclusive) and their squares and the sum of their squares. Write a program
java programs - Java Beginners
java programs  Actually i am searching for the source code ,algorithm and flow chart for prime number ...can u suggest me where can i find it???  Hi Friend, Try the following code: import java.util.*; class
Advertisements
Java programs for beginners
RoseIndia provides a long list of Java programs for beginners that too... the Java programs provided for beginners, as every latest topic and update... prepared these java programs describing every logic and method behind
Simple Java Programs for Beginners
RoseIndia brings you simple Java programs that can be used and downloaded... of Java programs covering every topic, method, keywords, classes, functions, etc. Programs on Hello World Array list, Linked list, Iterate list, Java swing
writing programs - Java Beginners
Programs in java
Programs in java  Hi, What are the best programs in java for a beginner? Thanks
java programs
java programs  Why word "static" is used in java programs
Java Programs
Java Programs  Hi, What is Java Programs? How to develop application for business in Java technology? Is there any tool to help Java programmer in development of Java Programs? Thanks
java programs
java programs  Explain types of Java programs. Also explain how to compile and run them.   Types of Java Programs: Standalone Applications Web Applications Enterprise Applications Console Application Web services
java programs
java programs  i need help in understanding the whole concept of the 13 java programs that i hav...here r de programs.. int i,j,m,n; m=Integer.parseInt(args [0]); n=Integer.parseInt(args [1]); System.out.print
java programs
java programs  A union B, transpose of matric, denomination of a given number i need java programs for this category?   Hi Friend, Transpose of matrix: import java.util.*; public class Transpose { public
programs in java
programs in java  . I need an application for managing an educational institute. That application should provide the details of Students Courses Faculty Fee details etc.., pl z guide me how to write these programe
java programs
java programs  write java applet program to display an image using drawimage method of an java graphic class
java programs
java programs  55555 54444 54333 54322 54321
java programs
java programs  problems 1 21 312 4123 51234
java programs
java programs  1.define frame? 2.what is the need for java programming? 3.list the events of classes? 4.define Event handling? 5.List event listener interface
java programs
java programs  please help in this series .. 55555 55554 55543 55432 54321
Java Programs
Java Programs  Hello. I need help with the following. Write a program that prompts the user for 2 different integers, then prints out the numbers between the 2 integers (inclusive) and their squares and the sum
The Beginners Guide to JAXB part 3
; -------------------------------------------- Let us now generate the java source...\*.java generated\impl\*.java generated\impl\runtime\*.java We get compilation... will create a java object tree and then send it to a file as xml document
Beginners in Java
Beginners in Java  Hi, I am beginners in Java, can someone help me... tutorials for beginners in Java with example? Thanks.   Hi, want to be command over Java, you should go on the link and follow the various beginners
Explain types of java programs
Explain types of java programs  Explain types of java programs   Types of Java Programs: Standalone Applications Web Applications Enterprise Applications Console Application Web services
Java for beginners
Java for beginners  Java for beginners Which is the best resource... Java video tutorial for beginners. Thanks   Hi, Here are the best resources for Learning Java for beginners: Java Video tutorial Java tutorials
how to execuite java programs???
how to execuite java programs???  I have jdk 1.6 installed in my pc.i want to execuite java programs in ms-dos for applet and without using applet.please tell me
how to execuite java programs???
how to execuite java programs???  I have jdk 1.6 installed in my pc.i want to execuite java programs in ms-dos for applet and without using applet.please tell me
Complete Java programming tutorials for beginners
Complete collection of Java programming tutorials for beginners is available... videos, Java programs and Java examples acts as an online tutor that helps... tutorials includes innumerous working Java programs, Java examples, lessons and Java
Java programs on students assesment
Java programs on students assesment  1) Write a Java program... is 3. Use an array to store the marks of the three subjects. (Use any...) The assessment is possible only if the student passes in all the 3 subjects. (Use any
Java guide for beginners
Java guide provided at RoseIndia for beginners is considered best to learn... topic, Videos with voice overs on Java programs and hundreds of Java examples... and understand it completely. Here is more tutorials for Java coding for beginners
java beginners - Java Beginners
java beginners   the patteren u received is not the actual patteren which i need the program i don't know why the patteren does not reach in proper formate to you . it was in upside down triangle form . at the top
Programming in Java for beginners
Programming in Java can be difficult sometimes especially for beginners... Java guide that has innumerous Java programs, examples, tutorials and videos. This Java guide not only helps the beginners in Java to learn the language
Which is the best Java tutorials for beginners?
Which is the best Java tutorials for beginners?  Hello, I am trying to find good tutorials for beginners. Which is the best Java tutorials for beginners? Thanks   Hi, Beginners should learn to develop simple programs
3 queries on java class
3 queries on java class  Hey. I need to do 3 queries on same class ( JAVA) One is to populate the combobox, the another one to populate tje jlist and the last one to use on button to open a file from database (BLOB) Can some

Ads