Java Assignment
Java Assignment
Technology
Bagarpur, Delhi Road, Moradabad-244001 (U.P.)
a static
as data
using a
a stack
18.
Write a program to count the number of occurrence of the character & in
a file given in the command line.
19.
Write a java program to print the character at every fifth byte of a file
given in command line.
20.
Create a FileInputStream to represent the file in the command line. Read
byte by byte. Typecast the byte to character and check whether it is a &. If yes
increment the count.
21.
Write a program to determine whether the two files given in command
line are identical.(Using RandomAccessFile)
Write a program to input a word from the user and remove the duplicate characters present in it.
Example:
INPUT abcabcabc
OUTPUT abc
INPUT javaforschool
OUTPUT javforschl
INPUT Mississippi
OUTPUT Misp
Write a program to accept a sentence which may be terminated by either . ? or ! only. Any other character
may be ignored. The words may be separated by more than one blank space and are in UPPER CASE.
Perform the following tasks:
(a)
Accept the sentence and reduce all the extra blank space between two words to
a single blank space.
(b)
Accept a word from the user which is part of the sentence along with its
position number and delete the word and display the sentence.
Test your program with the sample data and some random data:
Example 1
INPUT:
WORD TO BE DELETED: IS
WORD POSITION IN THE SENTENCE: 6
OUTPUT:
Example 2
INPUT:
AS YOU
WORD TO BE DELETED: SO
WORD POSITION IN THE SENTENCE: 4
OUTPUT:
5 : 30
5 : 40
5 : 45
5 : 47
Write a program which first inputs two integers, the first between 1 and 12 (both inclusive) and second between
0 and 59 (both inclusive) and then prints out the time they represent, in words.
Your program should follow the format of the examples above.
SAMPLE DATA :
1. INPUT :
TIME : 3,0
OUTPUT : 3 : 00 Three o clock
2. INPUT :
TIME : 7,29
OUTPUT : 7 : 29 Twenty nine minutes past seven
3. INPUT :
TIME : 6,34
OUTPUT : 6 : 34 Twenty six minutes to seven
4. INPUT :
TIME : 12,1
OUTPUT : 12 : 01 One minute past Twelve
5. INPUT :
TIME : 12,45
OUTPUT : 12 : 45 Quarter to One
Ad by unisales | Close
Question:
The input in this question will consist of a number of lines of English text consisting of the letters of the English
alphabets, the punctuation marks () apostrophe, (.) full stop, (,) comma , (;) semicolon , (:) colon and white
space. Write a program to print the words of the input in reverse order without any punctuation marks other than
blanks.
For example, Consider the following input text:
INPUT:
Enter number of sentences: 2
Enter the sentences:
This is a sample piece of text to illustrate this question
if you are smart you will solve this right.
OUTPUT: right this solve will you smart are you if question this illustrate to text of piece sample a is this
NOTE : Individual words (i.e. characters of every word) are not reversed
Test your program for the following data and some random data:
Sample Input 1 :
Enter number of sentences: 1
Enter the text: Do not judge a book by its cover.
Sample Output: Cover its by book a judge not do
Sample Input 2:
Enter number of sentences: 2
Enter the text:
Emotions, controlled and directed to work, is character.
By Swami Vivekananda.
Write a program to input a string (word). Convert it into lowercase letters. Count and print the frequency of each
alphabet present in the string. The output should be given as:
Sample Input: Alphabets
Sample Output:
==========================
Alphabet
Frequency
==========================
a
2
b
1
e
1
h
1
l
1
p
1
s
1
t
1
swaps the values of two Strings without using any third (temp) variable.