(adsbygoogle = window.adsbygoogle || []).push({});
/*WAP read charator form file and Display
if charator if is alphabet then reverse it Case
wheter it digit or Space
*/
import java.io.*;
class Slip1
{
public static void main(String args[])throws IOException
{
int c;
try
{
FileReader fr=new FileReader("a.txt");
while((c=fr.read())!=-1)
{
if(c>=65&&c<=90)
...
To copy the content one file into the another file while copying change the case of alphabet and replase all Digit by '*'.
(adsbygoogle = window.adsbygoogle || []).push({});
/*To copy the content one file into the another file
while copying change the case of alphabet
and replase all Digit by '*'.
*/
import java.io.*;
class Slip2
{
public static void main(String args[])throws IOException
{
int c;
try
{
FileReader fr=new FileReader("a.txt");
FileWriter fw=new FileWriter("b.txt");
while((c=fr.read())!=-1)
...
Count the Spaces in file
//Count the Spaces in file
(adsbygoogle = window.adsbygoogle || []).push({});
import java.io.*;
class Space
{
public static void main(String args[])throws IOException
{
int c,lcnt=1;
try
{
FileReader fr=new FileReader("Space.java");
while((c=fr.read())!=-1)
{
System.out.print((char)c);
if((char)c==' ')
{
lcnt ++;
}
}fr.close();
System.out.println("no...
Count the lines in file
//Count the lines in file
import java.io.*;
class Line
{
public static void main(String args[])throws IOException
{
int c,lcnt=1;
try
{
FileReader fr=new FileReader("Line.java");
while((c=fr.read())!=-1)
{
System.out.print((char)c);
if((char)c=='\n')
{
lcnt ++;
}
}fr.close();
System.out.println("no of lines io file"+lcnt);
}catch(Exception e)
{
System.out.println(e);
...
Count the Spaces,word,lines,space in file
//Count the Spaces,word,lines,space in file
import java.io.*;
class Count
{
public static void main(String args[])//throws IOException
{
int c,scnt=0,ccnt=0,lcnt=0,wcnt=0;
try
{
FileReader fr=new FileReader("Count.java");
while((c=fr.read())!=-1)
{
ccnt++;
if((char)c==' ')
{
scnt ++;
}
if((char)c=='\n')
{
lcnt++;
}
if((char)c==' '||(char)c=='\n')
...
Simple copy one file to another file and Display on the cmd prompt
(adsbygoogle = window.adsbygoogle || []).push({});
//Simple copy one file to another file and Display on the cmd prompt
import java.io.*;
class CopyDis
{
public static void main(String args[])throws IOException
{
int c;
try
{
FileReader fr=new FileReader("CopyDis.java");
FileWriter fw=new FileWriter("SimpleCopy.txt");
while((c=fr.read())!=-1)
{
fw.write(c);
System.out.print((char)c);
...
Simple copy one file to another file
(adsbygoogle = window.adsbygoogle || []).push({});
//Simple copy one file to another file
import java.io.*;
class Copy
{
public static void main(String args[])throws IOException
{
int c;
try
{
FileReader fr=new FileReader("Copy.java");
FileWriter fw=new FileWriter("SimpleCopy.txt");
while((c=fr.read())!=-1)
{
fw.write(c);
}
System.out.println("Copy Successfully");
...
WAP to accept n numbers from command line and stores all prime & perfect numbers in different array & display it.
By Sachin
September 11, 2015
(adsbygoogle = window.adsbygoogle || []).push({});
class
PrimePerfect
{
public static void main(String
arg[])
{
int...
WAP to accept n numbers from command line and stores all prime & perfect numbers in different array & display it.
By Sachin
September 11, 2015
(adsbygoogle = window.adsbygoogle || []).push({});
class
PrimePerfect
{
public static void main(String
arg[])
{
int num[]=new...
Write a java program to accept n name of cities & Sort them descending order.
(adsbygoogle = window.adsbygoogle || []).push({});
class
SortCity
{
public static void main(String
arg[])
{
String name[]=new
String[10];
...
Define abstract class Shape with abstract method area() & Volume().Calculate area & Volume of Cone & Cylinder.
(adsbygoogle = window.adsbygoogle || []).push({});
import java.io.*;
import java.lang.*;
abstract class Shape
{
float pi=3.14f;
abstract void area();
abstract void volume();
}
class Cone extends Shape
{
int red,side,height;
Cone(int r,int s,int h)
{
red=r;
side=s;
height=h;
}
void area()
{
float a=pi*red*side;
System.out.println("Area of Cone-"+a);
}
void volume()
{
float...
Create an interface Shape with method area() Calculate area of Circle and Sphere. (Use final keyword)
(adsbygoogle = window.adsbygoogle || []).push({});
import java.io.*;
interface Shape
{
final float pi=3.14f;
float area(int r);
}
class Circle implements Shape
{
public float area(int r)
{
return(pi*r*r);
}
}
class Sphere implements Shape
{
public float area(int r)
{
return(4*pi*r*r);
}
}
class ShapeDemo
{
public static void main(String arg[])
{
int r;
BufferedReader din=new...
WAP to accept n cricket player, display average run of single player & all players. (Use array of object, method overloading & static keyword).
(adsbygoogle = window.adsbygoogle || []).push({});
import java.io.*;
class Player
{
int p_code,run;
String p_name;
int i_played;
int nooftime_notout;
float avg;
void accept()
{
DataInputStream din=new DataInputStream(System.in);
try
{
System.out.print("Enter the player code-");
p_code=Integer.parseInt(din.readLine());
System.out.print("Enter the player name-");
p_name=din.readLine();
...