Posts

Showing posts from October, 2018

Practical 20 : Prepare a sequence diagram for issuing a book in the library management system

Image
Solution:

Practical 19 : Prepare an activity diagram for computing a restaurant bill, there should be charge for each delivered item. The total amount should be subject to tax and service charge of 18% for group of six and more. For smaller groups there should be a blank entry. Any coupons or gift certificates submitted by the customer should be subtracted

Image
Solution:

Practical 18 : Prepare a use case diagram and sequence diagram for a computer email system

Image
Solution:

Practical 17 : Prepare a state diagram for an interactive diagram editor for selecting and dragging objects

Image
Solution

Practical 16 : Categorize the following relationships into generalization, aggregation or association.

Image
[A] A country has a capital city Solution: [B] A dining philosopher uses a fork Solution: [C] A file is an ordinary file or a directory file Solution:                                                      [D] Files contains records Solution: [E] A polygon is composed of an ordered set of points Solution: [F] A drawing object is text, a geometrical object, or a group Solution: [G] A person uses a computer language on a object Solution: [H] Modems and keyboards are input/output devices Solution: [I] Classes may have several attributes Solution: [J] A person plays for a team in a certain year Solution: [K] A route connects two cities Solution: [L] A student takes a course from a professor Solution:

Practical 15: Prepare a class diagram for given group of classes using multiplicity, generalization, association concepts. And add at least 5-7 attributes and 3-5 operations for particular class. City, Airport, Airline, Pilot, Flight, Plane, Seat, Passenger

Image
Solution:

Practical 14: Prepare a class diagram for given group of classes using multiplicity, generalization, association concepts. And add at least 5-7 attributes and 3-5 operations for particular class Page, Shape, Point, Line, Arc, Ellipse, Rectangle, and Circle

Image
Solution:

Practical 13: Refine the student manager program to manipulate the student information from files by using the DataInputStream and DataOutputStream. Assume suitable data

Image
Program : import java.io.*; public class practical13 {     public static void main(String args[]) throws IOException {         DataInputStream dataIS = new DataInputStream(new FileInputStream("stdinfo.txt"));         DataOutputStream dataOS = new DataOutputStream(new FileOutputStream("newstdinfo.txt"));         // manipulate the student information from files         String str;         while ((str = dataIS.readLine()) != null) {             String upper = str.toUpperCase();             System.out.println(upper);             dataOS.writeBytes(upper + "  ,");...

Practical 12: Refine the student manager program to manipulate the student information from files by using the BufferedReader and BufferedWriter

Image
Program: import java.io.*; import java.util.*; class practical12 { public static void main(String pqr[]) throws Exception {         BufferedReader bufRead = new BufferedReader(new FileReader("stdinfo.txt"));         BufferedWriter bufWrite = new BufferedWriter(new FileWriter("newstdinfo.txt"));         int i;         // manipulate the student information from files         do {             i = bufRead.read();             if (i != -1) {                 if (Character.isUpperCase((char) i)) {            ...

Practical 11 : Create a class called Student. Write a student manager program to manipulate the student information from files by using FileInputStream and FileOutputStream

Image
Program : import java.io.FileInputStream; import java.io.FileOutputStream; public class practical11 {     public static void main(String[] args) {         System.out.println("-------Writing Data in File-------");         try {             FileOutputStream fout = new FileOutputStream("stdinfo.txt");             String str = "Nmae : Pruthviraj, Stream : INFORMATION TECHNOLOGY, Sem : 5th Sem";             byte b[] = str.getBytes();             fout.write(b);             fout.close();             System.out....

Practical 10 : Write an interactive program to print a diamond shape. For example, if user enters the number 3, the diamond will be as follows:

Image
              *           *      *      *        *       *          *         *              * Program: import java.util.Scanner; public class practical10 {     public static void main(String[] args)     {         int i, j, k;         Scanner scan = new Scanner(System.in);         int no = scan.nextInt();         for (i = 0; i < no; i++)         {             for (j = (no / 2) + 1; j >= i; j--)         ...

Practical 9 : Write an interactive program to print a string entered in a pyramid form. For instance, the string “stream” has to be displayed as follows:

Image
                  s                s     t              s    t     r          s     t     r    e       s     t    r      e   a    s     t    r     e      a   m Program: public class practical9    {     public static void main(String[] args)     {         int i, j, k;  String str = "Stream";         for (i = 0; i < str.length(); i++)       {             for (j = (str.length() / 2) + 1; j >= i; j--)  ...

Practical 8 : Create a class which ask the user to enter a sentence, and it should display count of each vowel type in the sentence. The program should continue till user enters a word “quit”. Display the total count of each vowel for all sentences.

Image
Program: import java.util.Scanner; public class practical8 {     public static void main(String[] args)     {         System.out.println("Enter the word 'quit' to end this program.");         String str;         int x = 0, A = 0, E = 0, I = 0, O = 0, U = 0;         char ch;         Scanner in = new Scanner(System.in);         while (x < 1) {             str = in.next();             if (str.equals("quit")) {                 x++;         ...

Practical 7: Write a program to find that given number or string is palindrome or not.

Image
Program: import java.util.*; class practical7 {    public static void main(String args[])    {       String original, reverse = "";       Scanner in = new Scanner(System.in);       System.out.println("Enter a string to check if it is a palindrome : ");       original = in.nextLine();       int length = original.length();       for ( int i = length - 1; i >= 0; i-- )          reverse = reverse + original.charAt(i);       if (original.equals(reverse))          System.out.println("Entered string is a palindrome.");       else          System.out.println(...

Practical 6: Write a program to count the number of words that start with capital letters.

Image
Program: import java.util.*; class practical6 {     public static void main(String m[])     {         Scanner in=new Scanner(System.in);         String s=new String();         System.out.println("Enter a line:");         s=in.nextLine();         char c;         int ct=0;         for(int i=0;i<s.length();i++)         {             c=s.charAt(i);             if(c>=65 && c<=90)             {   ...

Practical 5: Write a program to accept a line and check how many consonants and vowels are there in line.

Image
Program: import java.io.*; class practical5 { public static void main(String args[]) throws IOException { String str; int vowels = 0, digits = 0, blanks = 0; char ch; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter a String : "); str = br.readLine(); for(int i = 0; i < str.length(); i ++) { ch = str.charAt(i); if(ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch == 'o' || ch == 'O' || ch == 'u' || ch == 'U') vowels ++; else if(Character.isDigit(ch)) digits ++; else if(Character.isWhitespace(ch)) blanks ++; } System.out.println("Vowels : " + vowels); System.out.println("Digits : " + digits); System.out.println("Blanks : " + blanks); } } Output: