TYBCS Java Assignment 2 - Sem I


 SET A 

1.  Define a Student class (roll number, name, percentage). Define a default and parameterized constructor. Keep a count of objects created. Create objects using parameterized constructor and display the object count after each object is created. (Use static member and method). Also display the contents of each object.  

2.  Modify the above program to create n objects of the Student class. Accept details from the user for each object. Define a static method “sortStudent” which sorts the array on the basis of percentage.  

SET B
  
1.  Create a package named Series having three different classes to print series:  
a. Prime numbers 
b. Fibonacci series 
c. Squares of numbers 
Write a program to generate ‘n’ terms of the above series. 

2. Write a Java program to create a Package “SY” which has a class SYMarks (members – ComputerTotal, MathsTotal, and ElectronicsTotal). Create another package TY which has a class TYMarks (members – Theory, Practicals). Create n objects of Student class (having rollNumber, name, SYMarks and TYMarks).  Add the marks of SY and TY computer subjects and calculate the Grade (‘A’ for >= 70, ‘B’ for >= 60 ‘C’ for >= 50 , Pass Class for > =40 else ‘FAIL’) and display the result of the student in proper format. 

Post a Comment

3 Comments

  1. This link is good for the program learning as well as program beginner

    ReplyDelete
  2. Slip7_1: Design a class for Bank. Bank Class should support following operations;
    a. Deposit a certain amount into an account
    b. Withdraw a certain amount from an account
    c. Return a Balance value specifying the amount with details
    class Bank
    {
    private double balance;
    public Bank()
    {
    balance = 0;
    }
    public Bank(double initialBalance)
    {
    balance = initialBalance;
    }
    public void deposit(double amount)
    {
    balance = balance + amount;
    }
    public void withdraw(double amount)
    {
    balance = balance - amount;
    }
    public double getBalance()
    {
    return balance;
    }
    public static void main(String[] args)
    {
    Bank b = new Bank(1000);
    b.withdraw(250);
    System.out.println("the withdraw is:"+ b.balance);
    b.deposit(400);
    System.out.println("the deposit is:"+ b.balance);
    System.out.println("the balance is:"+ b.getBalance());
    }

    }
    Slip7_2: Write a program to accept a text file from user and display the contents of a file in
    reverse order and change its case.
    import java.io.*;
    import java.util.*;
    class ReverseFile
    {
    public static void main(String args[])throws IOException
    {
    Scanner sc = new Scanner(System.in);
    System.out.println("enter file name:");
    String fnm = sc.next();
    File f = new File(fnm);
    if(f.isFile())
    {
    BufferedInputStream bis = new BufferedInputStream(new
    FileInputStream(fnm));
    int size =bis.available();
    for(int i = size-1;i>=0;i--)
    {
    bis.mark(i);
    bis.skip(i);
    char ch=((char)bis.read());
    if(Character.isLowerCase(ch))
    ch=Character.toUpperCase(ch);
    else if(Character.isUpperCase(ch))
    ch = Character.toLowerCase(ch);
    System.out.print(ch);
    bis.reset();
    }
    bis.close();
    }
    else
    System.out.println("file not found");

    }
    }

    ReplyDelete