Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners 3 Java Programs for Beginners
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Zyvin Kyphos
3 Java Programs for Beginners
3 Answer(s)      2 years and 8 months ago
Posted in : Java 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.


Advertisement
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){}
}
}


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  Could you please write the followong programs for me.. Thanks in advance 1)1. write a program that reads a string composed of 12.... Then form 3 strings extracted from s: the first part of s that does not contain p
Advertisements
Java programs - Java Beginners
Java programs  Hello Please write the following programs for me using GUI.Thanks You. 1. Write a java program that reads the first name, last name, hours worked and hourly rate for an employee. Then print the name
programs - Java Beginners
information.http://www.roseindia.net/java/beginners/arrayexamples/java_array_usage.shtmlamar....Java Array Programs  How to create an array program in Java?  Hi public class OneDArray { public static void main (String[]args){ int
java programs - Java Beginners
java programs  1) write a program to print prime numbers? 2) write a program to print factorial of given number? 3)Please provide complete material...); } System.out.println(fac); } } 3)For hibernate, Please visit the following
java programs - Java Beginners
java programs   design a vehicle class hierachy in java.write a program to demonstrate polymorphism  Hi Friend, Try the following code... Polymorphism{ public static void main(String[]args){ Vehicle[] v = new Vehicle[3
java programs - Java Beginners
java programs  lisp-like list in java to perform basic operations such as car, cdr ,cons  Hi Friend, Try the following code: import...) { List l=new ArrayList(); l.add(3); l.add(0); l.add(2); l.add(5
java programs - Java Beginners
java programs  design a java interface for adt stack .develop two different classes that implement the interface one using array and another using... (menu) { case 1: stk.push(); break; case 2: stk.pop(); break; case 3
Java Programs - Java Beginners
Java Programs  Dear Sir, Could you give me the syntax for HIERARCHIAL INHERITANCE and give sample program for the same?(if possible with an output...://www.roseindia.net/java/language/inheritance.shtml Thanks
java programs - Java Beginners
java programs  take one file as a input exam.txt under this file 1,2,3,4,5 6,7,8,9,10 11,12,13,14,15 and give output in new file as result.txt under this file 1,6,11 2,7,12 3,8,13 4,9,14 5,10,15
java programs - Java Beginners
java programs  a coin is tossed for three sets of times i.e 10,100,1000.write to print how many times the head and tail occurs in each sets of toss and total number of head nand tail occured at the end.use method call
java programs - Java Beginners
java programs  i need a program for rational numbers to represent 500/1000 as 1/2 in java using java doc comments  Hi Friend, Try... rationalNumber(int p, int q) { if (q==0){ return p
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
java programs - Java Beginners
java programs   I am trying to write a program that prompts the user to enter the month and year and displays the number of days in the month. Need help  Hi Friend, Try the following code: import java.util.
java programs - Java Beginners
java programs  write a program to enter name of book,author's name,year of publication,and price of any 10 different books in respective arrays.then input an auther name and print all the details such as name of book ,auther's
programs - Java Beginners
program in Java.  Hi friend public class ThreeDArray { public static void main(String[] args) { int[][][] threeD = new int[5][4][3]; for (int i...; 3; ++k) { threeD[i][j][k] = i + j + k; System.out.print(" "
programs - Java Beginners
. (by using methods of minimum and maximum of numbers) 3. Write a Java program to demonstrate inheritance. 4. Write a Java program to demonstrate dynamic polymorphism. 5. Write a Java program to implement the following hierarchy
programs - Java Beginners
. (by using methods of minimum and maximum of numbers) 3. Write a Java program to demonstrate inheritance. 4. Write a Java program to demonstrate dynamic polymorphism. 5. Write a Java program to implement the following hierarchy
programs - Java Beginners
Program Java in Linux  How to program Java in Linux system
Abstract programs - Java Beginners
. http://www.roseindia.net/java/master-java/abstract-class.shtml Thanks
programs - Java Beginners
double array in java  Please give me an example of double array in java.  Hi friend public class TwoDArray { public static void main(String[] args){ int[][] twoD = new int[8][4]; for (int i=0; i<twoD.length; i
OOP with Java 3 - Java Beginners
OOP with Java 3  Write a Temperature class that has two instances variables: temperature value (a floating-point number) and a character for the scale, wither C for Celsius or F for Fahrenheit. the class should have four
java lab programs - Java Beginners
java lab programs  1. Develop a Java package with simple Stack... for Complex numbers in Java. In addition to methods for basic operations on complex numbers, provide a method to return the number of active objects created. 3
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
java lab programs - Java Beginners
java lab programs  Develop with suitable hierarchy, classes for Point, Shape, Rectangle, Square, Circle, Ellipse, Triangle, Polygon, etc. Design a simple test application to demonstrate dynamic polymorphism. 5. Design a Java
writing java programs - Java Beginners
writing java programs  How do i write a code to display even numbers from 1 to 50  Hi Friend, Try the following code: class EvenNumbers{ public static void main (String args[]){ String evenNo
java lab programs - Java Beginners
java lab programs  Design a Date class similar to the one provided in the java.util package.  Hi Friend, Try the following code: public class Date { private final int month; private final int day
what programs are needed in java programming? - Java Beginners
what programs are needed in java programming?  What programs are needed in java programming?   Hi friend, For solving the problem visit to : http://www.roseindia.net/java/] Thanks  Hi friend
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
Advertisements
 

 

 

DMCA.com