ahmedshayan 0 Newbie Poster

Thank you. I have solved the Problem, you are right the values were not assigning.

ahmedshayan 0 Newbie Poster
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Eventmanagement
{
    public partial class Registration : Form
    {
        SqlConnection aConnection;
        string firstname= string.Empty; 
        string lastname= string.Empty;
        int aid;
        string date = DateTime.Now.ToShortDateString();
        SqlDataAdapter da = new SqlDataAdapter();
        DataTable dta;


        public Registration(string fname, string lname, int attID)
        {
            this.firstname = fname;
            this.lastname = lname;
            this.aid = attID;
            InitializeComponent();
        }
        //--------------------------------------------//

        private void Registration_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'insertEventDataSet.Events' table. You can move, or remove it, as needed.

            populateEventSalesPersonList();
            populateEventNameIdTypeList();

            //+++++++++++++++++++++++++++++++++++++++++++//
            txtSalesTaxRate_Registration.Text = Convert.ToString( SalesTaxRate());
            txtRegistrationID_Registration.Text = regID().ToString();
            //+++++++++++++++++++++++++++++++++++++++++++//

            //+++++++++++++++++++++++++++++++++++++++++++//
            txtAttendee_Registration.Text = (this.firstname+" "+this.lastname);
            txtRegistrationDate_Registration.Text = date.ToString();


        }

        //--------------------------------------------//

        public string getConnectionString()
        {
            try
            {
                string sConnection = "";

                // Get the mapped configuration file.
                System.Configuration.ConnectionStringSettingsCollection ConnSettings = ConfigurationManager.ConnectionStrings;
                sConnection = ConnSettings["DBConnectionString"].ToString();

                return sConnection;


            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
                return "";
            }
        }



        //--------------------------------------------//
        public void populateEventNameIdTypeList()
        {
            try
            {
                cmbEvent_Registration.DataSource = getDataTable4();
                //----------------------------
                cmbEvent_Registration.ValueMember = "EventID";
                cmbEvent_Registration.DisplayMember = "EventName";




            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }


        }


        //--------------------------------------------//

        public void populateEventSalesPersonList()
        {
             try
            {

                cmbSalesPerson_Registration.DataSource = getDataTable5();
                cmbSalesPerson_Registration.ValueMember = "EmployeeID";
                cmbSalesPerson_Registration.DisplayMember = "SalesPerson";

            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }

        //-------------------------------------------//

        public void populateFeeScheduleByEventList()
        {

            try
            {

                cmbFeeSchedule_Registration.DataSource = getDataTable6(); 
                cmbFeeSchedule_Registration.ValueMember = "FeeScheduleID";
                cmbFeeSchedule_Registration.DisplayMember = "Fee";




                //--------------------------------------------------//

                //saleTax();
                //txtSalesTax_Registration.Text = Convert.ToString(saleTax());
                //txtTotalCharges_Registration.Text = Convert.ToString(totalCharges());
                //txtAmountDue_Registration.Text = Convert.ToString(amountDue());

                //--------------------------------------------------//
                }

            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }

        }

        //------------------------------------------//

        //------------------------------------------//



        private void btnclose_Registration_Click(object sender, EventArgs e) …
ahmedshayan 0 Newbie Poster

I have been trying to connect Database in Java for a quit time now. Following is the code. I have worked with .mdb extension, but this time I am using .accdb extension.
Database File.

import java.sql.*;
class DB{
 static Connection con;
 static Statement sta;
 static void getDBConnection(String path)
{
    try{
        System.out.println("-----Requesting the Connection---------");
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        con=DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+path);
        sta=con.createStatement();
        System.out.println("------------Connection Established");
    }
    catch(SQLException e)
    {
        System.out.println(e);
        e.printStackTrace();
    }
    catch(ClassNotFoundException e){
        System.out.println(e);
        e.printStackTrace();
    }
    }
public static Statement getStatement(){
    return sta;
}
public static void disconnectDB(){
    try{
        con.close();
        System.out.print("------Connection closed----");
    }
    catch(SQLException e){
        System.out.println(e);
        e.printStackTrace();
    }
}
}

Item File.

import java.sql.Statement;
import java.sql.ResultSet;
 class item
 {
    public void viewItem()
    {
        int col1Value=0;
        String col2Value=null;
        int col3Value=0;
        double col4Value=0.0;
        double total=col3Value*col4Value;
        DB dbConnect = new DB();
        dbConnect.getDBConnection("ZTBL.accdb");
        Statement statement = dbConnect.getStatement();
         String query = "SELECT * FROM item";
         try
         {
             ResultSet resultSet = statement.executeQuery(query);
             while (resultSet.next())
             {
                 col1Value = resultSet.getInt("Item Id");
                 col2Value = resultSet.getString("Item Name");
                 col3Value = resultSet.getInt("Quantity");
                 col4Value = resultSet.getDouble("Total Amount");
        /* Printing the data on the console */
        System.out.println(col1Value+ "    "+col2Value+"   "+col3Value+"  "+col4Value+"  "+total);
      } //end of while
    }//end of try
    catch(Exception exception)
    {
 	System.out.println("Exception while executing the Query: "+exception);
    }
    finally
    {
        dbConnect.disconnectDB();
    }
    }
 }

and Client file.

import java.sql.Statement;
import java.sql.ResultSet;
public class client
{
    public static void main(String[] args)
    {
            item a = new item();
            a.viewItem();
           // stock b=new stock();
            //b.viewstock();
    }
}

Please guys help me out!

ahmedshayan 0 Newbie Poster

I am faced this Problem that I can't print display parent's content. Please help:

import javax.swing.JOptionPane;
public class BinaryTree
{

  private Node root;

  BinaryTree()
     {
        root = null;
     }
//------------------------------------------------------------------
  void buildTree()
  {
      String n=JOptionPane.showInputDialog("Root Information:\nEnter Name: ");
      int a=Integer.parseInt(JOptionPane.showInputDialog("Root Information:\nEnter Age of Root:"));
      String s=JOptionPane.showInputDialog("Root Information:\nAlive or Dead?");
      String w=JOptionPane.showInputDialog("Root Information:\nMarried or unmarried?");
      root=new Node(n,a,s,w);

  }
//------------------------------------------------------------------
  public boolean Search(String data, int a)
      {
        return(Search(root, data, a));
      }

  private boolean Search(Node node, String data, int a)
    {

          if (node==null)
              {
               return(false);
              }
           if (data.equals(node.name))
              {
                    return(true);
              }
           else
              {
              if(a<=(node.age))
                   return(Search(node.left, data, a));
              else
                    return(Search(node.right, data, a));
              }

  }
 //-----------------------------------------------------------------------
  public void insert(String nvar,String cvar,int k,int avar,String s,String w)
  {
    root = insert(root,nvar,cvar, k, avar, s, w);

  }

  private Node insert(Node node,String nvar,String cvar,int k, int avar,String s,String w)
  {
      Node temp=new Node();
    if (node==null)
    {
      node = new Node(nvar,avar,s,w);
      node.parent=temp;
      System.out.println("\nNew Node Information:\n");
      node.display();
[b]      System.out.println("\nParent Node Information:\n");
      node.parent.display();[/b]
    }
    else
    {
      if (cvar.equals(node.name) && k==node.key && avar<node.age)
      {
        temp=node;
        node.left = insert(node.left,nvar,cvar,k,avar,s,w);
      }
      else
      {
        node.right = insert(node.right,nvar,cvar,k,avar,s,w);
      }
    }

    return(node); // in any case, return the new pointer to the caller
  }
  public void printTree()
   {
     printTree(root);
     System.out.println();
   }
   private void printTree(Node node)
   {
     if (node == null)
         return;

     printTree(node.left);
     System.out.println("Information Of Node"+node.key+"\n\tName:"+node.name + "\n\tLife Status:"+node.status+"\n\tMartial Status "+node.wife);
    // printTree(node.parent);
     printTree(node.right);
   }
}

and here is the Node file:

public class Node
{
    Node parent;
    Node left;
    Node right;
    static int count=0;
    int key;
    String name;
    int age;
    String status;
    String wife;

    Node()
    { …
ahmedshayan 0 Newbie Poster

I have created this program, and it works fine for random values .
But when I ever enter same Arrival time it gives error output !
.i.e arrivaltime bursttime
p1 0 10
p2 0 6
now the problem is that instead of p2 running first p1 starts...
plz help.
Process.h

#include <iostream>
using namespace std;
class Process
{
private:
	int bstTime,wtTime,arrTime;
	int procNo; int procTime;
	int trArTime;int startTime; int endTime;
public:
	Process()
	{
		bstTime=wtTime=arrTime=trArTime=0;
		procTime=0;
	}
	Process(int bT, int arT)
	{
		bstTime=bT;
		arrTime=arT;
	}
	/////////////////////////////////////////
	void setBstTime(int bTime)
	{
		bstTime=bTime;
	}
	///////////////////////////////////////
	void setArrTime(int arTime)
	{
		arrTime=arTime;
	}
////////////////////////////////////////
	 void getInput(int i)
	 {
		 cout<<"\t\tEnter the Burst Time of the   P"<<i<<" : ";;cin>>bstTime;
		 procTime=bstTime;
		 cout<<"\t\tEnter the Arrival Time of the P"<<i<<" : ";cin>>arrTime;
		 procNo=i;
		
	 }
	 ////////////////////////////////////
	 int getBstTime()
	 {return bstTime;}
	 //////////////////////////////////
	 int getWtTime()
	 {
		 return wtTime;
	 }
	 ////////////////////////////////////
	 int getArrTime()
	 {return arrTime;}
	 /////////////////////////////////////
	 int getProcID()
	 {return procNo;}
	 ///////////////////////////
	 //Decrease Remaining time
	 void decProcTime()
	 {
		 if(procTime>0)
		 procTime--;
	 }
	 ///////////////////get time to be processed 
	 int getProcTime()
	 {return procTime;}
	 //////////////////////////////////////////
	 void setStartingTime(int t)
	 {startTime=t;}
	 //////////////////////////////////////////
	 void setEndingTime(int t)
	 {endTime=t;}
	 //////////////////////////////////////////
	 int getStartTime()
	 {return startTime;}
	 //////////////////////////////////////////
	 int getEndingTime()
	 {return endTime;}
	 //////////////////////////////////////////
	void calcWaitingTime()
	 {
		 wtTime=(endTime-bstTime-arrTime);
		 trArTime=wtTime + bstTime;
		
	 }
	 //////////////////////////////////Get Turn around Time

	 int getTurnAroundTime()
	 {
		 return trArTime;
	 }
	 /////////////////////////////////////////////////
	 int getWaitingTime()
	 {return wtTime;}


};

and .cpp file

#include "process.h"
#include <sstream>
#include <string>

stringstream st,st1,st2;

void sortAgain(Process pro[], int no, int t)		//Sorting the processes
{
for(int i=0;i<no;i++)
{
	for(int j=0;j<no;j++)
		if((pro[j].getProcTime()>pro[j+1].getProcTime())&&(pro[j+1].getArrTime()==t)&& (pro[j].getArrTime()<t))
			
		{
			st<<char(179); …
ahmedshayan 0 Newbie Poster

I am in desperate need of help... I were to create Operating System's Shortest Job First Preemptive Algorithm .... The problem is that I am not getting how to calculate the average waiting time of each process... HELP !
SJF.java:

import javax.swing.JOptionPane;
import java.util.*;
public class SJF {
int process=0;
int BurstTime[]=new int[20];
int ArrivalTime[]=new int[20];
int in=0;
int totaltime=0;
int temp[],temp1,temp2,temp3;
SJF h[]=new SJF[20];
    public void setProcess(int t){
        process=t;
    }
    public int getProcess(){
        return process;
    }
    void getData(){
        in=Integer.parseInt(JOptionPane.showInputDialog("Enter Number of Processes:"));
        for(int i=0;i<in;i++){
            int bt=Integer.parseInt(JOptionPane.showInputDialog("Enter Burst Time of Process P"+(i+1)));
            BurstTime[i]=bt;
        }
        for(int i=0;i<in;i++){
            int at=Integer.parseInt(JOptionPane.showInputDialog("Enter Arrival Time of Process P"+(i+1)));
            ArrivalTime[i]=at;
        }
       }
    void cpuScheduale(){
        for(int i=0;i<in;i++){
        h[i]= new SJF();
        totaltime=totaltime+BurstTime[i];
        h[i].setProcess(i);
        System.out.println(h[i].getProcess());
        }
        System.out.println("Your Input:");
            System.out.println("----------------------");
            System.out.println("Process"+"    "+"Burst Time"+"     "+"Arrival Time");
        for(int i=0;i<in;i++){
            int t=h[i].getProcess();
            System.out.println("P"+(t+1)+"               "+BurstTime[i]+"               "+ArrivalTime[i]);
        }
            
          }

              void Compare(){
                 /*for(int i=0;i<in;i++){
               if(BurstTime[i]>BurstTime[i+1]){
                   temp=BurstTime[i];
                   BurstTime[i]=BurstTime[i+1];
                   BurstTime[i+1]=temp;
                   Arrays.sort(ArrivalTime, 0, in);
                   System.out.println(BurstTime[i]+" "+ArrivalTime[i]);
               }*/
                for(int i=0;i<in;i++){
                    if(BurstTime[i]>BurstTime[i+1]){
                  Arrays.sort(ArrivalTime, i, in);
                   h[i].setProcess(temp1);
                  Arrays.sort(BurstTime, i, in);
                    }
                       System.out.println(BurstTime[i]+" "+ArrivalTime[i]);
           }
}
              void Calc(){
                 /* for(int i=0;i<in;i++){
                      for(int j=ArrivalTime[i];j>0;j--){
                      if(ArrivalTime[i]<ArrivalTime[j+1]){
                          System.out.println("Hey");
                      }
                      else{
                          System.out.println("Nay man");
                      }
                      System.out.println();
                      }
                  }*/
                  for(int i=0;i<in;i++){
                      temp[i]=BurstTime[i]-ArrivalTime[i];
                  }
              }
ahmedshayan 0 Newbie Poster

Yes I have to Include TooHotException but I already getting error with TooColdException!

ahmedshayan 0 Newbie Poster

The toString() method has public access privileges which you can't change. If you want to override it, you need to make your method public as well. Also, the toString method returns a String, while yours returns void. Change your method name to: public String toString(). And return a String in the method.

First of Thanks for quick reply !
now I am faced with one more problem, now when i have created VirtualPerson class and VirtualCafe class. I am getting Incompatible types error !
VirtaulPerson:

package Cafe;


public class VirtualPerson {
public void drinkCoffee(CoffeeCup cup,double temp){
    if(temp>=65&&temp<85){
        throw new TooColdException("Cold!");
    }
    else if(temp>=85){
        throw new TooHotException("Hot!");
    }
}
}

and VirtualCafe:

package Cafe;
import java.Exception.TemperatureException.*;

public class VirtaulCafe {
static void serveCustomer(VirtualPerson customer,CoffeeCup cup,double temp){
   try{
       customer.drinkCoffee(cup, temp);
   }
   catch(TooColdException e){
       System.out.println(e.toString());
   }
}
}

Thanks in ADvance !

ahmedshayan 0 Newbie Poster

This is the Program I am try create !
Create a class CoffeeCup with a double instance variable temperature. Provide a parameterized constructor, an accessor/getter, and a mutator/setter. It may be noted that 75 degree Celsius is considered best temperature for coffee to be served for drinking.

Create another class TeaCup with a double instance variable temperature. Provide a parameterized constructor, an accessor/getter, and a mutator/setter. It may also be noted that 70 degree Celsius is considered best temperature for tea to be served for drinking.

Create TemperatureException, TooColdException, and TooHotException classes as drawn in the exception hierarchy below. Each exception class should include a default constructor and a parameterized constructor with one String parameter. Also override toString method in each exception class to return description of exception.


Create another class VirtualPerson with methods drinkCoffee(CoffeeCup acup) and drinkTea(TeaCup acup), each of which should throw TooColdException or TooHotException respectively if the coffee or tea to be served is either too cold or too hot. 65 degree Celsius should be considered too cold temperature for coffee and 85 degree Celsius should be considered too hot temperature for coffee. Similarly, 60 degree Celsius should be considered too cold temperature for tea and 80 degree Celsius should be considered too hot temperature for tea.

Create another class VirtualCafe with a static method serveCustomer(VirtualPerson customer, CoffeeCup acup) overloaded as serveCustomer(VirtualPerson customer, TeaCup acup). First version should invoke drinkCofee and second should invoke drinkTea method of VirtualPerson from within …

ahmedshayan 0 Newbie Poster

Thanks javaAddict . Problem solved .

ahmedshayan 0 Newbie Poster

javaAddict ! plz rectify me here .....

empID=JOptionPane.showInputDialog("Enter your Employee ID:");

/*acc[i].JobTitle(empID,acc,n);
break;*/
for(int j=0;j<Employee.count;j++){
if(empID.equals(acc[i].getjobTitle())){
n=JOptionPane.showInputDialog("Enter your New Job Title:");
acc[i].JobTitle(n);
System.out.println(acc[i].getjobTitle());
}
}
ahmedshayan 0 Newbie Poster

this is what i did

import java.util.Scanner;
import javax.swing.JOptionPane;
class BusinessConcern{
public static void main(String []args){
String empID,n;
//Scanner enter=new Scanner(System.in);
//System.out.print("How many account(s) do wish to create ? ");
//int num=enter.nextInt();
int num=Integer.parseInt(JOptionPane.showInputDialog("How many account(s) do wish to create ? "));
Employee acc[]=new Employee[num];
for(int i=0;i<acc.length;i++){
acc[i]=new Employee();

int choice=0;

System.out.println("What do you want to do ? ");
System.out.println("New Employee (1)");
System.out.println("Change Job Title (2)");
System.out.println("Change Monthly Income (3)");
System.out.println("Change Mailing Address (4)");
System.out.println("Employee Details (5)");
System.out.println("Available Records (6)");
System.out.println("Exit (7)");

choice=Integer.parseInt(JOptionPane.showInputDialog("Enter your choice"));

switch(choice){
case 1:
acc[i].NewEmployee();
System.out.println(acc[i].getjobTitle());
break;

case 2:
empID=JOptionPane.showInputDialog("Enter your Employee ID:");

/*acc[i].JobTitle(empID,acc,n);
break;*/
for(int j=0;j<acc.length;j++){
if(empID.equals(acc[i].getjobTitle())){
acc[i].JobTitle();
System.out.println(acc[i].getjobTitle());
}
}
break;
case 7:
System.exit(0);
break;

}
}

}//2ND LAST
}//LAST BRACKET

and what i comprehended ...

import javax.swing.JOptionPane;
class Employee
{
private String firstName;
private String lastName;
private String jobTitle;
private String employeeID;
private double monthlyIncome;
private String joiningDate;
private String mailingAddress;
static int count=0;

Employee()
{
firstName=" " ;
lastName=" " ;
jobTitle=" " ;
employeeID=" " ;
monthlyIncome=0.0;
joiningDate=" " ;
mailingAddress=" " ;
count++;
}
Employee(String f,String l,String j,String e,double m,String join,String mail)
{
firstName=f ;
lastName=l ;
jobTitle=j ;
employeeID=e ;
monthlyIncome=m;
joiningDate=join ;
mailingAddress=mail ;
count++;
}
Employee(Employee emp)
{
firstName=emp.firstName;
lastName=emp.lastName;
jobTitle=emp.jobTitle ;
employeeID=emp.employeeID ;
monthlyIncome=emp.monthlyIncome;
joiningDate=emp.joiningDate ;
mailingAddress=emp.mailingAddress ;
count++;
}

void setfirstName(String f)
{
firstName=f;
}
void setlastName(String l)
{
lastName=l;
}
void setjobTitle(String j)
{
jobTitle=j;
}
void setemployeeID(String e)
{
employeeID=e;
}
void setmonthlyIncome(double m)
{
monthlyIncome=m;
}
void setjoiningDate(String join)
{ …
ahmedshayan 0 Newbie Poster

Write a class Employee. An employee has a private first name (string), private last name (string), private job title (string), private employment ID (string), private monthly income (double), private joining date (string), and private mailing address (string). Provide a default constructor, a parameterized constructor, and a clone constructor. Write separate setters and getters for each private instance variable. Your Employee class should also keep track of number of employees that have been added to your system.

Write another class BusinessConcern, which acts as your main class. Inside main method, create a one-dimensional array of objects of Employee type. At the start of your program, it should prompt for total number of employee records to be added to the system. After creating an array of desired number of employees, your program shall provide a console-based menu to user with following options:
1) New Employee Record (input: values for initialization of instance variables of new employee object/instance)
2) Change Job Title (required input: employment ID, new job title)
3) Change Monthly Income (required input: employment ID, new monthly income)
4) Change Mailing Address (required input: employment ID, new mailing address)
5) Employee Details (required input: employment ID)
6) List All Available Records
7) Exit Program
I have been working on this project for quit some hours .... But it seems to be not working ... here is the class Employee

import javax.swing.JOptionPane;
class Employee
{
private String firstName;
private String lastName;
private …
ahmedshayan 0 Newbie Poster

1. Create a class Account that has following instance variables:
a. private account number (string)
b. private account holder name (string)
c. private balance (floating-point)
d. private account opening date (string)
e. profitRate (final, floating-point): 5% for all accounts

Supply a default constructor, a parameterized constructor, and a clone constructor. Write a setter and a getter for each private instance variable. Also include following methods:
a. withdraw: deducts a specified amount from balance
b. deposit: adds a specified amount to the balance
c. accountStatement: displays all information of an account
d. creditProfit: calculates the profit using profitRate and updates account balance

Account class should also keep track of number of accounts that have been opened at any given time.

Write another class Bank, which acts as your main class. Inside main method, create a one-dimensional array of objects of Account type. At the start of your program, it should prompt for total number of accounts to be created. After creating an array of desired number of accounts, your program shall provide a console-based menu to user with following options:
1) Open an Account (required input: values for initialization of instance variables of new account object/instance)
2) Withdraw an Amount (required input: account number, amount to withdraw)
3) Deposit an Amount (required input: account number, amount to deposit)
4) Account Statement (required input: account number)
5) Credit Profit (required input: account number)
6) …