Thursday, July 5, 2012

Assignment No. 05 Semester: Spring 2012 CS201: Introduction to Programming


 #include <iostream.h>
#include <string.h>
#include <conio.h>
#include <iomanip.h>
using namespace std;
class Customer
{
      friend istream& operator >> ( istream & is, Customer &d );
      friend ostream& operator << ( ostream & is, Customer &d );
      friend ostream &star(ostream &);
     public:
             Customer();
             Customer(string, int, int);
             void setName(string);
             void setCID(int);
             void setSpend(int);
             string getName();
             int getCID();
             int getSpend();
           
         
      private:
              string name;
              int id;
              int spending;
              friend void sum(Customer&);  
              float tax;  
              float discount;
              double totalbill;  
};

istream &operator >>(istream & is, Customer &d)
             {
                     cout<<"Enter the name of Customer : ";
                     cin>>d.name;
                     cout<<"Enter the id of Customer : ";
                     cin>>d.id;
                     cout<<"Enter total spending by Customer : ";
                     cin>>d.spending;
                     return is;
};

ostream & star(ostream & output)
{
        output<<"*";
        return output;
};
//-----------------------------------------------------------------------
Customer::Customer()
{
        name = "no name";
        id=0;
        spending=0;
}
Customer::Customer(string n, int id, int spend)
{
      name = n;
      this->id=id;
      spending=spend;
};
//====================================================================
ostream & operator <<(ostream & output, Customer & c)
{      
 for(int i=0;i<55;i++)
        {
                if(i==25)
                {
                         output<<"Customer Bill Information";
                }
                else
                {
                    output<<star;
                }
        }
        output<<endl;
        output<<"Name :";
        for(int a=0;a<21;a++)
        {
                if(a==20)
                {
                 output<<c.name<<endl;
                }
       
                else
                {
                 output<<star;
                }
        }
        output<<"ID :";
        for(int a=0;a<23;a++)
        {
        if(a==22)
                {
                 output<<c.id<<endl;
                }
       
                else
                {
                 output<<star;
                }
        }
        output<<"Spending :";
        for(int a=0;a<19;a++)
        {
        if(a==18)
                {
                 output<<c.spending<<endl;
                }
       
                else
                {
                 output<<star;
                }
        }
     
        if(c.spending<=5000)
        {
                         c.tax=(c.spending*5)/100;
                         c.discount=(c.spending*1)/100;
                         c.totalbill=c.spending+c.tax-c.discount;
                         output<<"Tax :";
                                      for(int a=0;a<27;a++)
                                      {
                                              if(a==26)
                                              {
                                               output<<c.tax<<endl<<"Discount :";
                                                   for(int a=0;a<19;a++)
                                                   {
                                                       if(a==18)
                                                       {
                                                         output<<c.discount<<endl<<"Total Bill :";
                                                             for(int a=0;a<17;a++)
                                                             {
                                                                if(a==16)
                                                                {
                                                                  output<<c.totalbill<<endl;
                                                                  }
       
                                                                      else
                                                                      {
                                                                        output<<star;
                                                                      }
                                                                  }
                 
                                                                 }
       
                                                              else
                                                              {
                                                               output<<star;
                                                              }
                                                         }
               
               
                                                    }
       
                                                 else
                                                 {
                                                  output<<star;
                                                  }
                                              }
                       
                                          }
        else if(c.spending>5000 & c.spending<10000)
        {
             c.tax=(c.spending*10)/100;
                         c.discount=(c.spending*2)/100;
                         c.totalbill=c.spending+c.tax-c.discount;
                         output<<"Tax :";
                                      for(int a=0;a<27;a++)
                                      {
                                              if(a==26)
                                              {
                                               output<<c.tax<<endl<<"Discount :";
                                                   for(int a=0;a<19;a++)
                                                   {
                                                       if(a==18)
                                                       {
                                                         output<<c.discount<<endl<<"Total Bill :";
                                                             for(int a=0;a<17;a++)
                                                             {
                                                                if(a==16)
                                                                {
                                                                  output<<c.totalbill<<endl;
                                                                  }
       
                                                                      else
                                                                      {
                                                                        output<<star;
                                                                      }
                                                                  }
                 
                                                                 }
       
                                                              else
                                                              {
                                                               output<<star;
                                                              }
                                                         }
               
               
                                                    }
       
                                                 else
                                                 {
                                                  output<<star;
                                                  }
                                              }
                       
                                          }

        else if(c.spending>10000)
        {
             c.tax=(c.spending*15)/100;
                         c.discount=(c.spending*3)/100;
                         c.totalbill=c.spending+c.tax-c.discount;
                         output<<"Tax :";
                                      for(int a=0;a<27;a++)
                                      {
                                              if(a==26)
                                              {
                                               output<<c.tax<<endl<<"Discount :";
                                                   for(int a=0;a<19;a++)
                                                   {
                                                       if(a==18)
                                                       {
                                                         output<<c.discount<<endl<<"Total Bill :";
                                                             for(int a=0;a<17;a++)
                                                             {
                                                                if(a==16)
                                                                {
                                                                  output<<c.totalbill<<endl;
                                                                  }
       
                                                                      else
                                                                      {
                                                                        output<<star;
                                                                      }
                                                                  }
                 
                                                                 }
       
                                                              else
                                                              {
                                                               output<<star;
                                                              }
                                                         }
               
               
                                                    }
       
                                                 else
                                                 {
                                                  output<<star;
                                                  }
                                              }
                       
                                          }
return output;
};
//====================================================================


main()
{
      Customer obj;
      cin>>obj;
      cout<<obj;
getch();
}

Sunday, June 24, 2012

CS201Assignment No. 04 Semester: Spring 2012 CS201: Introduction to Programming



#include <iostream.h>

class location
{
      public:
           location();
           location(int j,int i);
           void display();
           void* operator new (size_t);
           void operator delete(void*);
           location operator ++();
           location operator --();
      private:
        int longitude;
        int latitude;    
};
location::location()
{
    longitude=0;
    latitude=0;        
}
location::location(int j,int i)
{
    longitude=j;
    latitude=i;
}

void location::display()
{
    cout<<"\n Longitude : "<<longitude;
    cout<<"\n Latitude : "<<latitude;
}

void* location::operator new(size_t size)
{
    cout<<"\nOverloaded New operator Called"<<endl;    
    void *pointer=malloc(size);
    return pointer;
}

void location::operator delete(void *p)
{
     cout<<"\nOverloaded delete operator Called"<<endl;
     free(p);
}

location location::operator ++()
{
    longitude+=1;
    latitude+=1;
}

location location::operator --()
{
    --longitude;
    --latitude;
}

main()
{
    location *loc,l2;
    loc=new location(10,20);
    loc->display();
    cout<<"\nAfter calling Overloaded ++ operator";
    ++*loc;
    loc->display();
    cout<<"\n";
    l2=location(30,40);
    l2.display();
    --l2;
    cout<<"\nAfter calling Overloaded -- operator";
    l2.display();
    delete loc;
    system ("pause");
}

Thursday, June 21, 2012

cs604 GDB solution Operating System fall june 2012


Suppose a computer lab contains two printers, three tape drives, and four terabyte crystal ROM writers. Assume process 2 is currently using a printer and two crystal ROM writers, process 1 is using a tape drive, and process 3 is using two crystal ROM writers, a tape drive, and a printer.
Suppose now that process 2 requires a tape drive, process 1 requires a printer, and process 3 requires one more crystal ROM writer. Does there exist any safe sequence or not? Give reason/justification to support your answer.”
If you will give invalid reason/justification then you will get zero marks with no leniency. Give reason precisely and briefly to support your comments. The more you will be precise and brief in your comments the more you will get the marks. 

Solution:

Yes there exists safe state.
When all processes take their resources then only one tape drive remained free. Process 2 require 1 tape drive so process 2 gets it. After using it and P2 free all its resources and now P1 Get Printer Resource which is freed by P2. Now Process 3 Used 2 ROM, 2 ROM are already freed by P2. SO we can easily say this that system is in safe state, no deadlock. 

Tuesday, June 12, 2012

Assignment No. 03 Semester: Spring 2012CS201: Introduction to Programming


 #include <iostream.h>
#include <string.h>
#include <conio.h>
using namespace std;
class Customer
{
     public:
             Customer();
             Customer(string, int, int);
             void setName(string);
             void setCID(int);
             void setSpend(int);
             string getName();
             int getCID();
             int getSpend();
      private:
              string name;
              int id;
              int spending;
              friend void sum(Customer&);            
};
//-----------------------------------------------------------------------
Customer::Customer()
{
        name = "no name";
        id=0;
        spending=0;
}
Customer::Customer(string n, int id, int spend)
{
      name = n;
      this->id=id;
      spending=spend;
}
void Customer::setName(string n)
{
      name = n;
}
void Customer::setCID(int n)
{
     id = n;
}
void Customer::setSpend(int n)
{
     spending = n;
}
string Customer::getName()
{
       return name;
}
int Customer::getCID()
{
    return id;
}
int Customer::getSpend()
{
     return spending;
}
//-----------------------------------------------------------------------
void sum(Customer &cus)
{
     double tax=0,d=0,t=0;
     if(cus.spending < 5000)
     {
                     tax = cus.spending*.05;
                     d = cus.spending*.01;
     }
     else if(cus.spending > 5000 && cus.spending < 10000)
     {
                     tax = cus.spending*.10;
                     d = cus.spending*.02;
     }
     else if(cus.spending > 10000)
     {
                     tax = cus.spending*.15;
                     d = cus.spending*.03;
     }
     t = cus.spending+tax-d;
    
     cout<<"Customer Name :\t\t"<<cus.name<<endl;
     cout<<"ID :   \t\t\t"<<cus.id<<endl;
     cout<<"Spending :\t\t"<<cus.spending<<endl;
     cout<<"Total Bill :\t\t"<<t<<endl<<endl<<endl;
}


main()
{
      Customer *cus1 = new Customer();
      Customer *cus2 = new Customer("Ali", 112, 8550);
      Customer *cus3 = new Customer();
     
      cout<<"Bill detail for customer 1"<<endl;
      sum(*cus1);
      cout<<"Bill detail for customer 2"<<endl;
      sum(*cus2);
      char n[30];
      int i;
      int s;
      cout<<"Enter the name of customer 3 : ";
      cin>>n;
      cout<<"Enter the ID of the customer 3 : ";
      cin>>i;
      cout<<"Enter total spending of customer 3 : ";
      cin>>s;
      cus3->setName(n);
      cus3->setCID(i);
      cus3->setSpend(s);
     
      cout<<"\nBill detail for customer 3"<<endl;
      sum(*cus3);
getch();
}

Monday, April 30, 2012

CS201 2 introduction to programming assignment solution fall 2012


#include <iostream.h>
#include <conio.h>

int highest(int[],int);
int lowest(int[],int);
float average(int[],int);

main()
{
      int nmbr,*ptr, high, low;
      float avg;
      cout<<"Enter the number of consecutive days to read their temperature : ";
      cin>>nmbr;
      ptr= new int[nmbr];
      for (int i =0; i<nmbr; i++ )
      {
          cout<<"\nEnter temperature for day "<<i+1<<" : ";
          cin>>ptr[i];
      }
      avg = average(ptr, nmbr);
      high =highest(ptr, nmbr);
      low = lowest(ptr, nmbr);
     
      cout<<"\n\nThe average temperature is \t"<<avg<<endl;
      cout<<"The highest temperature is \t"<<high<<endl;
      cout<<"The lowest  temperature is  \t"<<low<<endl;
getch();    
}

float average (int arr[], int size)
{
      float total=0;
      float avg;
      for (int i=0;i<size;i++)
      total = total + arr[i];
      avg = total/size;
      return avg;
}

int highest (int arr [], int size)
{
    int big = arr[0];
    for(int i=0; i<size; i++)
    if (big < arr[i])
    big = arr[i];
    return big;
}

int lowest (int arr [], int size)
{
    int small = arr[0];
    for(int i=0; i<size; i++)
    if (small > arr[i])
    small = arr[i];
    return small;
}

Tuesday, April 17, 2012

CS506 - Web Design and Development Assignment 1 solution fall 2012

Solution includes three java files copy source code in three different files(AddressBook.java , Student.java , Assignment1.java). zip these files and submit the zip folder.


File = AddressBook.java 





import java.util.*;
import javax.swing.*;

public class AddressBook {
 ArrayList mylist;
 ArrayList projectlist;

 //default constructor
 public AddressBook(){
     mylist = new ArrayList();
     projectlist = new ArrayList();
 }

 public void addToBook(){
     Student std1 = new Student();
     std1.addStudent();
     mylist.add(std1);
     JOptionPane.showMessageDialog(null,"Now size is " + mylist.size());;
 }
 //search student function
 public void searchStudent(){
     String search = JOptionPane.showInputDialog("Enter Roll Number for search");
     Student std;
     int i = 0;
  for( i = 0; i < mylist.size(); i++){
      std = (Student) mylist.get(i);
      if(search.equals(std.rollnum)){
      JOptionPane.showMessageDialog(null,"Name: " + std.name + "\nRoll Number: "+ std.rollnum + "\nPrograme: " + std.programe + "\nPhone: " + std.phone + "\nStatus: " + std.status);
   
      } else   {
          JOptionPane.showMessageDialog(null,"Student record not found for " + search);
      }
  }
 }

 //Function to delete a student
  public void deletStudent(){
      String delete = JOptionPane.showInputDialog("Enter Roll number to delete");
      Student std1;
          for(int i = 0; i < mylist.size(); i++){
              std1 = (Student) mylist.get(i);
              if(delete.equals(std1.rollnum)){
                  mylist.remove(i);
                  JOptionPane.showMessageDialog(null, "Student deleted successfully for roll number" + delete);
               
              }else if(!delete.equals(std1.rollnum)){
                  JOptionPane.showMessageDialog(null, "No record found for" + delete);
              }
          }
  }

  //add project to projectlist
  public void addProject(){
      String search0 = JOptionPane.showInputDialog("Enter a roll number to add project");
      Student s = new Student();
      Student.Projects proj = s.new Projects();
      for(int i = 0; i < mylist.size(); i++){
          s = (Student) mylist.get(i);
          if(search0.equals(s.rollnum)){
              proj.addProject();
              projectlist.add(proj);
              break;
          } else {
              JOptionPane.showMessageDialog(null, "There found no such roll number to add a project for " + search0);
          }
      }
   
  }

  //find projects
  public void findProject()
  {
      String search1 = JOptionPane.showInputDialog("Entter rollnumber to search project");
      Student std2 = new Student();
      for(int i = 0; i < mylist.size(); i++)
 {
       std2 = (Student) mylist.get(i);
       if(search1.equals(std2.rollnum)) {
          Student stdp = new Student();
          Student.Projects prj = stdp.new Projects();
          for(int j = 0; j < projectlist.size(); j++){
              prj = (Student.Projects) projectlist.get(j);
              if(search1.equals(prj.rollnumber)){
                 JOptionPane.showMessageDialog(null, "Roll Number:" + prj.rollnumber + "\nProject Title: " + prj.title + "\nCurrent Phase:" + prj.cPhase + "\nProject Status:" + prj.pStatus);
                 break;
              } else {
                  JOptionPane.showMessageDialog(null, "There's found no project for " + search1);
              }
          }
       } else if(!search1.equals(std2.rollnum)){
           JOptionPane.showMessageDialog(null, "There's found no record for " + search1);
       }
    }
}

    public void deleteProject()
{
      String search1 = JOptionPane.showInputDialog("Entter rollnumber to delete project");
      Student std2 = new Student();
      for(int i = 0; i < mylist.size(); i++){
       std2 = (Student) mylist.get(i);
       if(search1.equals(std2.rollnum)) {
          Student stdp = new Student();
          Student.Projects prj = stdp.new Projects();
          for(int j = 0; j < projectlist.size(); j++){
              prj = (Student.Projects) projectlist.get(j);
              if(search1.equals(prj.rollnumber)){
projectlist.remove(j);
JOptionPane.showMessageDialog(null, "Project has been deleted");
                 break;
              } else {
                  JOptionPane.showMessageDialog(null, "There's found no project for " + search1);
              }
          }
       } else if(!search1.equals(std2.rollnum)){
           JOptionPane.showMessageDialog(null, "There's found no record for " + search1);
       }
      }
  }
}


File = Student.java 




import javax.swing.*;

public class Student {
    public String name, rollnum, programe, status;
   public int phone;

//default Constructor
   public Student(){
       name = "No name";
       rollnum = "BC0000";
       phone = 0000000;
       status = "no status";
   }
 
   //Function for add a student
   public void addStudent(){
       name = JOptionPane.showInputDialog("Enter Student Name");
       rollnum = JOptionPane.showInputDialog("Enter Roll Number");
       programe = JOptionPane.showInputDialog("Enter Programe Name");
       String ph = JOptionPane.showInputDialog("Enter Phone Number");
       phone = Integer.parseInt(ph);
       String st = JOptionPane.showInputDialog("Enter status\n0 for blocked\n1 for active");
      if(st.equals("0")){
          status = "Blocked";
      } else if(st.equals("1")){
          status = "Active";
      }
     
   }
   //inner class for projects
 
   public class Projects{
       public String rollnumber;
       public String title;
       public String cPhase;
       public String pStatus;
     
       //default constructor
       public Projects(){
           rollnumber = "no rollnumber";
           title = "No title";
           cPhase = "No Phase";
           pStatus = "No project Status";
       }
     
       //Add project to a student
       public void addProject(){
       rollnumber = JOptionPane.showInputDialog("Enter Student roll number");
       title = JOptionPane.showInputDialog("Enter project title");
       cPhase = JOptionPane.showInputDialog("Enter current phase");
       pStatus = JOptionPane.showInputDialog("Enter project status");
   }
 


  }
}





File = Assignment1.java 



import javax.swing.*;

public class Assignment1 {

    public static void main(String[] args) {
        // TODO code application logic here
        String input;
        int ch;
        AddressBook ab = new AddressBook();
        while(true)
{
            input = JOptionPane.showInputDialog("1 for add\n2 for Search \n3 for delete student \n4 for add project \n5 for find project  \nEnter 6 to delete all projects of a student\nEnter 7 to exit the Application");
            ch =Integer.parseInt(input);
            switch(ch){
                case 1:
                    ab.addToBook();
                    break;
                case 2:
                    ab.searchStudent();
                    break;
                case 3:
                    ab.deletStudent();
                    break;
                case 4:
                    ab.addProject();
                    break;
                case 5:
                    ab.findProject();
                    break;
case 6:
ab.deleteProject();
break;
                case 7:
                    System.exit(1);
                    
            }
        }  
}
}

Sunday, March 18, 2012

Final Project fall spring 2012



Project Title
Multipurpose Viva Exam System
(Mobile & Web)

Project Description

This system will provide the facility of entering marks of students in a live environment, such as in viva voce examination. The viva panel members will register through the web interface of the application. Once registered, the panel members can use the application installed on their cell phones, to connect to the main system, and enter marks. This will be handled via bluetooth i.e. the connection between main system and mobile application will be implemented using Bluetooth technology. At the end of viva voce examination, the system will gather all the entered marks and calculate average marks which will be sent to the main system. When the marking will be completed, the web based system will calculate the total marks for student and generate a final marking sheet in PDF or DOC format.

Supervisor
Usman Waheed
Application Type
This is a twofold application; there will be a web based application and a mobile based application.
Possible Students
1 to 2
Required Aptitude
Motivated to work hard to deal with challenging tasks.
Required Background
Good in programming skills
Proposed Tools & Tech
For web application: Microsoft.Net, Java
For mobile application: J2ME, Android

Further Information
For further information/explanation/material  please contact at as5@vu.edu.pk







Project Title
Social Networks Marketing Engine

Project Description
Social websites like Face book and Twitter have become very popular recently and they could potentially provide valuable information such as current market trend. The general goal of this project is to understand the underlying social networks, extract useful information, and utilize the collected data in decision making. Here are some issues that can be addressed in the project.

Here we are aimed to develop a system with high level capability of offering more enhanced marketing support. Here our proposed system will extract useful features regarding customer habits and likes to form a database and offer the related ads or promotions for that category.  
Scope of System
System will offer a great deal of capability for more targeting business marketing. Here we will target the products or services to customer with similar behavior, likes and dislikes. This system will be more efficient regarding offering a great deal of support for more enhanced business support for its clients.    

Supervisor
Adnan Ashraf
Application Type
WIN / WEB
Possible Students
1 to 2
Required Aptitude
Motivated to work hard to deal with challenging tasks.
Required Background
Good in programming skills
Proposed Tools & Tech
C++, Java, dot Net Technologies or Matlab
Further Information
For further information/explanation/material  please contact at adnan.ashraf@vu.edu.pk   (dot after adnan)




















































Project Title
Poultry Farming System
Project Description
In Pakistan the consumption of white meat and eggs has gradually increased in recent years due to growing health awareness. The cheapest source of animal protein available in Pakistan is broiler meat and eggs. Poultry applies to a wide variety of birds of several species including chicken, pigeons, ducks, ostriches, quails etc but for this system it will cover up two common type of chicken i.e. one for meat purposes and one for eggs production.


Supervisor
Ch. Adnan Asif
Application Type
Desktop
Possible Students
1 to 2                                                                    
Required Aptitude
Motivated to work hard.
Required Background
Good programming skills.
Proposed Tools & Tech
It will be a Desktop application using Microsoft.Net/Java as front end tool and MS SQL server or My SQL as backend database.

Further Information
For further information/explanation/material  please contact at adnanasif@vu.edu.pk










































Project Title
Online Restaurant Coupon Deals

Project Description
The website will include the following core elements: 

§ Elegant & Interactive Design
§ Home page with latest news, offers etc.
§ General content pages for static information (About Us, Services, Contact Us etc.)
§ Dynamic search engine 
§ Image gallery and dynamic flash header module
§ News/Events 
§ Online payment gateways (Paypal)
§ Email notifications
§ Website Feed
§ Newsletter subscription form
§ Affiliate system with complete commission tracking and b2b/b2c options
§ Blogs
§ Newsletter subscription form
§ Contact / enquiry forms
§ Live Chat/Live Help as an option
§ All managed by a bespoke CMS 

Supervisor
Tanweer Arshad
Application Type
Desktop
Possible Students
1 to 2                                                                    
Required Aptitude
Motivated to work hard.
Required Background
Good programming skills.
Proposed Tools & Tech
It will be a Desktop application using Microsoft.Net/Java as front end tool and MS SQL server or My SQL as backend database.

Further Information
For further information/explanation/material  please contact at as2@vu.edu.pk