0% found this document useful (0 votes)
122 views5 pages

CAP310 Modern Programming Tools & Techniques I: Homework 3

This document is a homework submission for a modern programming tools and techniques course. It contains the student's declaration that the work is their own, as well as evaluator comments section. The content of the homework assignment begins on the next page and includes two programming problems - one to reverse a sentence and print vowel counts, and another involving multiple threads printing output.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
0% found this document useful (0 votes)
122 views5 pages

CAP310 Modern Programming Tools & Techniques I: Homework 3

This document is a homework submission for a modern programming tools and techniques course. It contains the student's declaration that the work is their own, as well as evaluator comments section. The content of the homework assignment begins on the next page and includes two programming problems - one to reverse a sentence and print vowel counts, and another involving multiple threads printing output.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1/ 5

CAP310

Modern Programming Tools & Techniques


I
HOMEWORK 3

Submitted To– Submitted By-


Lect. Satinder Saini Surendra
MCA 4th SEM
D3804A15
10806601
Declaration:

I declare that this assignment is my individual work. I have


not copied from any other student’s work or from any other
source except where due acknowledgment is made explicitly
in the text, nor has any part been written for me by another
person.

Student’s
Signature:

surend
ra

Evaluator’s comments:
_____________________________________________________________
________

Marks obtained: ___________ out of ______________________


Content of Homework should start from this page
only:
PART A

1 Write a program that inputs a sentence at runtime. And prints the number of
occurrences of each vowel in it. Further the program must also print the word by word
reverse of the sentence.

Example: If the input string is “What is True in World”, then the output would be as
follows:

VOWEL COUNT

A 1

E 1

I 2

O 1

U 1

The word-wise Reverse is: TAHW SI EURT NI DLROW

ANSWER:

Reverse of sentence:

public class JavaStringBufferReverseExample

public static void main(String[] args)

//create StringBuffer object

StringBuffer sb = new StringBuffer("I LOVE INDIA");

System.out.println("Original StringBuffer Content : " + sb);

//To reverse the content of the StringBuffer use reverse method

sb.reverse();

System.out.println("Reversed StringBuffer Content : " + sb);

}
ANS:

class A extends Thread

public void run()

for(int i=1;i<=5;i++)

System.out.println("\t thread A:i="+i);

System.out.println("Exit from A");

class B extends Thread

public void run()

for(int j=1;j<=5;j++)

System.out.println("\t From thread B:j="+j);

System.out.println("Exit from B");

class C extends Thread

public void run()


{

for(int k=1;k<=5;k++)

System.out.println("Thread C:k="+k);

System.out.println("Exit from C");

class Thread1

public static void main(String args[])

new A().start();

new B().start();

new C().start();

You might also like