Please help me in this program
I'm having problem with geting the balls bounce appropriately when they collide in my bouncingball program.Can somebody give me an idea how to do it.
The main problem I'm having is in order to collide two balls I need to compare two balls moving on the screen, How do I compare those balls since they are same object .
Here is my Ball class
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Ball
private int x;
private int y;
private int theta = (int)(Math.random() * (-2 * Math.PI));
private int xv;
private int yv;
public int xMax=350;
public int yMax=350;
public static int r = 15;
private Color color;
BouncingBall space;
public Ball(BouncingBall spacex, int ballx, int bally,
int xMax, int yMax, Color ballcolor)
x = ballx;
y = bally;
xv = (int)(r * (Math.cos(theta))) ;
yv = (int)(r * (Math.sin(theta)*r));
this.xMax = xMax;
this.yMax = yMax;
color = ballcolor;
space = spacex;
public void setXmax(int newXmax)
xMax= newXmax;
public void setYmax(int newYmax)
yMax = newYmax;
public void Bounce()
int xn = x + xv;
int yn = y + yv;
if (xn > xMax){
x = xMax;
xv = -xv;
else if (xn < 0)
x = 0;
xv = -xv;
else{
x = xn;
if (yn > yMax)
y = yMax;
yv = -yv;
else if (yn < 0)
y = 0;
yv = -yv;
else{
y = yn;
space.repaint();
public void draw(final Graphics g){
//g.setColor(g.getBackground());
g.setColor(color);
g.fillOval(x - r/2, y - r/2, r, r);
Bounce();
And here is my BouncingBall class
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BouncingBall extends JFrame
private int x;
private int y;
private int xv;
private int yv;
private int R;
private int G;
private int B;
private Color color;
public int xMax=400;
public int yMax=400;
public static int r = 15;
private MouseHandler mh;
public static ArrayList<Ball> ballsList;
Ball thisBall;
BouncingBall bb;
public BouncingBall()
super( "Click in the window to add balls" );
ballsList = new ArrayList<Ball>();
mh = new MouseHandler( );
addMouseListener( mh );
setSize( xMax, yMax );
setVisible( true );
bb = this;
private class MouseHandler extends MouseAdapter{
public void mouseClicked(MouseEvent me){
x = me.getX();
y = me.getY();
R = 0 + (int) (256 * Math.random());
G = 0 + (int) (256 * Math.random());
B = 0 + (int) (256 * Math.random());
color = new Color(R, G, B);
ballsList.add(thisBall = new Ball(bb, x, y, xMax, yMax, color));
repaint();
public void paint(Graphics g)
super.paint(g);
for (Ball b : ballsList)
b.setXmax(this.getWidth());
b.setYmax(this.getHeight());
b.draw(g);
repaint();
public static void main(String [] args){
BouncingBall app = new BouncingBall();
app.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
Don't create multiple postings on the same topic.
If you make a mistake then reply to the posting asking people to respond to the other posting:
http://forum.java.sun.com/thread.jspa?threadID=725596&tstart=0
That way all comments are in a single place and its easier to see what has been suggested already so people don't waste time making suggestion that have already been made.
Also, use the "Code' button when posting code so the code retains its original formatting and is therefore readable.
Similar Messages
-
PLEASE HELP ME. THIS PROGRAM IS KILLING ME.
Hi. I am getting so sick of this program. I have been trying to do it for the past couple of weeks and I am getting nowhere. I really wish someone can help me on it ... like totaly help me on it. I am getting so frustrated. I would appreciate all the help.
This is the program:
In Belageusia, a plorg has these properties:
Data:
A plorg has a name
A plorg has a contentment index (CI), which is an integer between 0 and 100
The population of plorgs in Belagersia is further subdivided into three mutually exclusive classes: Plebeians, Equidians, and Elitians.
A Plorg?s stature is completely determined by their contentment index and witht that designation comes certain burdens and/or advantages.
Plebeians have a contentment index in [0, 24].
Each new Plebeian is welcomed with a contentment index of 2 and burdened with a debt of $10.00
Plebeians never manage to break even, so they have no taxes imposed upon them. Furthermore, since they can never get out debt, they cannot accumulate any wealth.
Equidians have a contentment index in [25, 75]
Each new Equidian is welcomed with a contentment index of 50 and burdened with taxes of $20.00
Equidians have taxes imposed upon them. Furthermore, since they do manage to break even, they have no debt. However, since they only manager to break even, they do not accumulate any wealth.
Elitians have a contentment index in [76, 100]
Each new Elitian is welcomed with a contentment index of 87 and burdened with taxes of $20.00, but also provided with a ?silver spoon? of $30.00 in accumulated wealth.
Elitians manage to expand upon their wealth, sot hey have taxes imposed upon them. Furthermore, since they are accumulating wealth, they have no debt.
At each interim time epoch the population of Belageusia retracts with a death rate randomly selected between 0% and 10%. If a plorg survives the purge, they have an opportunity to move one class higher and/or one class lower. However, remember that a plorg?s name is final. It never changes.
For Plebeians this is transition is determined by randomly selecting a CI in [0, 49]. If this new CI is les than 25 then the plorg remains a Plebeian, with this newly assigned CI, and their debt increases 3.7%. If this new CI is in [25, 49], the Plebeian ascends to a Equidian, with this newly assigned CI, their debt is forgiven, but taxes of $20 are assessed.
For Equidians this is determined by randomly selecting a CI in [0,100].
If this new CI is in [25, 75] then the plorg remains a Equidian, with this newly assigned CI, but their taxes are increased 6.1%.
If this new CI is in [0, 24] then the plorg becomes a Plebeian, with this newly assigned CI, their taxes are forgiven, but they are burdened with a debt of $10.00.
If this new CI is in [76, 100] then the plorg becomes a Plebeian, with this newly assigned CI, but their taxes are increased 6.1%. However, they are bewtowed a wealth of $30.00.
For Eletians this is determined by randomly selecting a CI in [51, 100]. If this new CI is greater than 76 then the plorg remains an Eletian, with this newly assigned CI, their taxes increase 6.1% and their wealth increases 4.9%. If this new CI is in [51, 75], then this plorg becomes an Equidian, with this newly assigned CI, their wealth is eliminated, and their taxes are increased 6.1%.
At each time epoch, the population of Belageusia at a birth rate randomly selected between 0% and 10%. A randomly chosen number between 0-100 determines each newly born plorg?s stature. If this random number is in the range 0-24, create a new Plebeian. In the range 25-75, create a new Equidian, and if in the range 76-100, create a new Elitian.
We are supposed to output the population characteristics of Belageusia, after 1000 time epochs.
This is the code that I wrote down but got no where with:
import javax.swing.*;
import java.util.*;
import java.text.*;
public class Belageusiaplorg
public static void main (String[] args)
ArrayList Plebs = new ArrayList(350);
ArrayList Equids = new ArrayList(600);
ArrayList Elits = new ArrayList(350);
ArrayList Holding = new ArrayList(600);
for (int i=0; i<25; i++)
Plebs.add(new plebian());
for (int i=0; i<50; i++)
Equids.add(new equidian());
for (int i=0; i<25; i++)
Elits.add(new Elitian());
long population = Plebs.size() + Equids..size() + Elits.size();
System.out.println("Current Belageusia Population is "+population);
System.out.println("Current Plebeians Population is "+Plebs.size);
System.out.println("Current Equidians Population is "+Equids.size);
System.out.println("Current Elitians Population is "+Elits.size);
Random generator = new Random();
int x = generator.nextInt(11);
for (int j=0; j=plebs.size(); j++)
System.out.println(Plebs.g(j));
long Equids_size = Equids.size();
long Elits_size = Elits.size();
for(int j=1; j<Plebs.size(); j++)
Plebian e = (Plebian) Plebs.get(j);
int new_ci = generator.nextInt(50);
if (new_ci < 25)
e.setCI(new_ci);
e.raiseDebt();
else
Plebs.rename(j);
Equids.add(new Equidian(e.getName().newCI));
j++;
for(int j=0; j < Equids.size; j++)
Equidian e = (Equidian) Equids.get(j);
int newCI = generator.nextInt(101);
if(new_ci < 25)
Equids.remove(j);
Plebs.add(nwe Plebian(e.getName().new_ci));
Equids_size --;
j++;
else
if (new_ci > 75)
Equids.remove(j);
Elitian f = new Elitian(e.getName(),new_ci,e.getTaxes());
Elits.add(f);
Equids_size --;
j--;
else
e.setCI(new_CI);
e.raiseTaxes();
for (int j=0; j<Elits.size; j++)
Elitian e = (Elitian) Elits.get(j);
int ci = e.getCI();
int r = generator.nextINT(50);
int new_ci = 51+r;
if(new_ci > 75)
e.setCI(new_ci);
e.raisetaxes();
e.raisewealth();
else
Elitians.remove(j);
Equidian g = new Equidian(e.getName(), new_ci);
g.raisetaxes();
Equids.add(g);
Elits_size --;
j--;
if(deathrate != 0)
int multiple = 100/deathrate;
int count 1;
for (int j=0; j=Plebs.size(); j++)
if(count % multiple == 0)
Plebs.remove(j);
j--;
count++;
class Plorg
private final String name;
private int CI;
private static long nextID = 1;
public Plorg()
name = "Plorg" + nextID;
nextID++;
public Plorg(int CI)
name = "Plorg" + nextID;
nextID++;
this.CI = CI;
public Plorg (String name, int CI)
this.name = name;
this.CI = CI;
public void setCI(int new_CI)
CI = new_CI;
public String getName()
return name;
public int getCI()
return CI;
public Plorg Plebs()
public Plorg Equids()
public Plorg Elits()Sounds a lot like a homework question to me. Still it was interesting enough to try out. I have not tried to change your code, just made one of my own. Here is my solution. I have made the Plorg class an inner class of the Belageusia. This is just so I dont have to put up two java files. You could easily split it into two though.
import java.util.Random;
import java.util.ArrayList;
import java.util.Iterator;
* @author Jonathan Knight
public class Belageusia
/** Random number generator - Seeded with the current time. */
private static Random random = new Random(System.currentTimeMillis());
/** A list of all of the Plorgs */
private ArrayList population = new ArrayList();
/** A list of all of the Plebians. */
private ArrayList plebians = new ArrayList();
/** A list of all of the Equidians. */
private ArrayList equidians = new ArrayList();
/** A list of all of the Elitians. */
private ArrayList elitians = new ArrayList();
/** A count of the Epochs that have passed */
private int epochs = 0;
* Main method.
* Create a new world of Belageusia and run it for 1000 epochs.
public static void main(String[] args)
Belageusia world;
world = new Belageusia();
for (int i = 0; i < 1000; i++)
world.epoch();
System.out.println("The Belageusia population after 1000 epochs");
world.printPopulation();
* Create a new World of Belageusia and create some Plorgs to live there.
* The world will be created with 25 Plebians, 50 Equidians and 25 Elitians.
public Belageusia()
for (int i = 0; i < 25; i++)
plebians.add(Plorg.createPlebian());
for (int i = 0; i < 50; i++)
equidians.add(Plorg.createEquidian());
for (int i = 0; i < 25; i++)
elitians.add(Plorg.createElitian());
* Print the current population to System.out
public void printPopulation()
int total;
int plebianCount;
int equidianCount;
int elitianCount;
plebianCount = plebians.size();
equidianCount = equidians.size();
elitianCount = elitians.size();
total = plebianCount + equidianCount + elitianCount;
System.out.println("Current Belageusia population is " + total);
System.out.println("Current Plebian population is " + plebianCount);
System.out.println("Current Equidian population is " + equidianCount);
System.out.println("Current Elitian population is " + elitianCount);
* At each interim time epoch the population of Belageusia retracts with a death rate
* randomly selected between 0% and 10%. If a plorg survives the purge, they have an
* opportunity to move one class higher and/or one class lower. However, remember that
* a plorgs name is final. It never changes.
* For Plebeians this transition is determined by randomly selecting a CI in [0, 49].
* If this new CI is les than 25 then the plorg remains a Plebeian, with this newly assigned CI,
* and their debt increases 3.7%. If this new CI is in [25, 49], the Plebeian ascends to a
* Equidian, with this newly assigned CI, their debt is forgiven, but taxes of $20 are assessed.
* For Equidians this is determined by randomly selecting a CI in [0,100].
* If this new CI is in [25, 75] then the plorg remains a Equidian, with this newly assigned CI,
* but their taxes are increased 6.1%.
* If this new CI is in [0, 24] then the plorg becomes a Plebeian, with this newly assigned CI,
* their taxes are forgiven, but they are burdened with a debt of $10.00.
* If this new CI is in [76, 100] then the plorg becomes a Plebeian, with this newly assigned CI,
* but their taxes are increased 6.1%. However, they are bewtowed a wealth of $30.00.
* For Eletians this is determined by randomly selecting a CI in [51, 100].
* If this new CI is greater than 76 then the plorg remains an Eletian, with this newly assigned CI,
* their taxes increase 6.1% and their wealth increases 4.9%. If this new CI is in [51, 75],
* then this plorg becomes an Equidian, with this newly assigned CI, their wealth is eliminated,
* and their taxes are increased 6.1%.
* At each time epoch, the population of Belageusia at a birth rate randomly selected between 0% and 10%.
* A randomly chosen number between 0-100 determines each newly born plorg?s stature.
* If this random number is in the range 0-24, create a new Plebeian. In the range 25-75, create a new Equidian,
* and if in the range 76-100, create a new Elitian.
public void epoch()
ArrayList newPlebians = new ArrayList();
ArrayList newEquidians = new ArrayList();
ArrayList newEletians = new ArrayList();
Iterator it;
Plorg plorg;
int deathRate;
double deathCount;
int birthRate;
double birthCount;
int population;
int subClass;
int newCI;
int kill;
epochs++;
System.out.println("Epoch = " + epochs);
printPopulation();
population = plebians.size() + equidians.size() + elitians.size();
// The death rate is random 0 to 10%
deathRate = random.nextInt(11);
// work out the death count. population is cast to a double to avoid rounding errors
deathCount = (double)population * deathRate / 100;
// round up the result. We do this as once the population falls below 10
// we would never kill anything
deathCount = Math.ceil(deathCount);
// We now work out the birth rate based on the population before we kill
// anything otherwise the population tends to go down and down
// The birth rate is random 0 to 10%
birthRate = random.nextInt(11);
// work out the birth count. population is cast to a double to avoid rounding errors
birthCount = Math.ceil((double)population * birthRate / 100);
// As with the deathCount round up the result.
// We do this as once the population falls too low we would never create any more
birthCount = Math.ceil(birthCount);
System.out.println("About to kill " + deathRate + "% which is " + deathCount + " Plorgs out of " + population);
for(int i=0; i<deathCount; i++)
// get a random number between 0 and 2
kill = random.nextInt(population);
population--;
// kill the specified Plorg
if( kill < plebians.size() )
// kill a random Plebian
plebians.remove( random.nextInt(plebians.size()) );
else if( kill < plebians.size() + equidians.size() )
// kill a random Equidian
equidians.remove( random.nextInt(equidians.size()) );
else
// kill a random Elitian
elitians.remove( random.nextInt(elitians.size()) );
System.out.println("Transitioning Plebians");
// Transition period for Plebians
it = plebians.iterator();
while ( it.hasNext() )
plorg = (Plorg) it.next();
// select a new CI from 0 to 49 at random
newCI = random.nextInt(50);
plorg.setCI(newCI);
if( newCI < 25 )
// Oh dear, this one stays as a Plebian; increase its dept by 3.7%
plorg.setDept( plorg.getDept() * 1.037 );
else
// Congratulations this one is now an Equidian
newEquidians.add(plorg);
// remove from the Plebian list.
// NOTE we must do the remove via the Iterator
it.remove();
plorg.setDept(0);
plorg.setTaxes(20);
System.out.println("Transitioning Equidians");
// Transition period for Equidians
it = equidians.iterator();
while ( it.hasNext() )
plorg = (Plorg) it.next();
// select a new CI from 0 to 100 at random
newCI = random.nextInt(101);
plorg.setCI(newCI);
if( newCI < 25 )
// Oh dear, this one becomes a Plebian
newPlebians.add(plorg);
// remove from the Equidian list.
// NOTE we must do the remove via the Iterator
it.remove();
plorg.setDept( 10 );
plorg.setTaxes(0);
else if( newCI < 25 )
// This one stays as an Equidian; increase its taxes by 6.1%
plorg.setTaxes( plorg.getTaxes() * 1.061 );
else
// Congratulations this one is now an Eletian
newEletians.add(plorg);
// remove from the Equidian list.
// NOTE we must do the remove via the Iterator
it.remove();
plorg.setWealth(30);
// Increase its taxes by 6.1%
plorg.setTaxes( plorg.getTaxes() * 1.061 );
System.out.println("Transitioning Elitians");
// Transition period for Eletians
it = plebians.iterator();
while ( it.hasNext() )
plorg = (Plorg) it.next();
// Always increase taxes by 6.1%
plorg.setTaxes( plorg.getTaxes() * 1.061 );
// select a new CI from 51 to 100 at random
newCI = 51 + random.nextInt(50);
plorg.setCI(newCI);
if( newCI > 76 )
// This one stays as an Eletian; increase its wealth by 4.9%
plorg.setWealth( plorg.getWealth() * 1.049 );
else
// Oh dear, this one becomes an Equidian
newEquidians.add(plorg);
// remove from the Plebian list.
// NOTE we must do the remove via the Iterator
it.remove();
// emove its wealth
plorg.setWealth(0);
// now assign the Plorgs that are transitioning
plebians.addAll(newPlebians);
equidians.addAll(newEquidians);
elitians.addAll(newEletians);
System.out.println("Creating " + birthRate + "% new Plorgs from " + population + " which is " + birthCount);
//create the new Plorgs
for (int i = 0; i < birthCount; i++)
// get a random number between 0 and 100
subClass = random.nextInt(101);
// create the specified Plorg
if( subClass <= 24 )
plorg = Plorg.createPlebian();
plebians.add(plorg);
else if( subClass >= 25 && subClass <= 75 )
plorg = Plorg.createEquidian();
equidians.add(plorg);
else
plorg = Plorg.createElitian();
elitians.add(plorg);
public static class Plorg
/** Identifier used to generate unique names */
private static int id = 0;
/** The Plorgs name */
private final String name;
/** The level of wealth for this Plorg */
private double wealth = 0;
/** The level of dept for this Plorg */
private double dept = 0;
/** The level of taxes for this Plorg */
private double taxes = 0;
/** This Plorgs contentment index */
private int ci = 0;
/** Create a new Plorg with the given CI.
* This is a private constructor. The only way for a program to
* create new Plorgs is by calling either createPlebian(),
* createEquidian() or createElitian().
* @param ci
private Plorg(int ci)
// Generate a unique name and iincrement the ID
this.name = "Plorg" + id++;
// assign the CI
this.ci = ci;
* Create a new Plebian.
* Plebeians have a contentment index in [0, 24].
* Each new Plebeian is welcomed with a contentment index of 2 and burdened
* with a debt of $10.00. Plebeians never manage to break even, so they have
* no taxes imposed upon them. Furthermore, since they can never get out debt,
* they cannot accumulate any wealth.
* @return a new Plebian.
public static Plorg createPlebian()
Plorg plebian;
plebian = new Plorg(2);
plebian.setDept(10);
return plebian;
* Create a new Equidian
* Equidians have a contentment index in [25, 75].
* Each new Equidian is welcomed with a contentment index of 50 and burdened
* with taxes of $20.00. Equidians have taxes imposed upon them. Furthermore,
* since they do manage to break even, they have no debt. However, since they
* only manager to break even, they do not accumulate any wealth.
* @return a new Equidian.
public static Plorg createEquidian()
Plorg equidian;
equidian = new Plorg(50);
equidian.setTaxes(20);
return equidian;
* Create a new Elitian.
* Elitians have a contentment index in [76, 100].
* Each new Elitian is welcomed with a contentment index of 87 and burdened
* with taxes of $20.00, but also provided with a ?silver spoon? of $30.00 in
* accumulated wealth. Elitians manage to expand upon their wealth, so they
* have taxes imposed upon them. Furthermore, since they are accumulating
* wealth, they have no debt.
* @return a new Elitian.
public static Plorg createElitian()
Plorg equidian;
equidian = new Plorg(87);
equidian.setWealth(30);
equidian.setTaxes(20);
return equidian;
* Returns this Plorgs name.
public String getName()
return name;
* Returns the CI of this Plorg.
public int getCI()
return ci;
* Set the new Contentment index for this Plorg
* @param ci
public void setCI(int ci)
this.ci = ci;
* Returns the Dept of this Plorg
* @return
public double getDept()
return dept;
* Set the dept of this Plorg.
* @param dept - the new dept for the Plorg.
public void setDept(double dept)
this.dept = dept;
* Returns the wealth of this Plorg.
public double getWealth()
return wealth;
* Sets the wealth of this Plorg.
* @param wealth - the new wealth of this Plorg.
public void setWealth(double wealth)
this.wealth = wealth;
* Returns the taxes of this Plorg.
public double getTaxes()
return taxes;
* Set the taxes of this Plorg.
* @param taxes - the new taxes for this Plorg.
public void setTaxes(double taxes)
this.taxes = taxes;
* Check for equality. If the object specified is a Plorg with the same name as this
* Plorg they are deemed to be equal.
* @param o - The object to check
public boolean equals(Object o)
if ( this == o ) return true;
if ( !(o instanceof Plorg) ) return false;
final Plorg plorg = (Plorg) o;
if ( name != null ? !name.equals(plorg.name) : plorg.name != null ) return false;
return true;
* Create a Hash Code for this Plorg
public int hashCode()
return (name != null ? name.hashCode() : 0);
} -
Please help me debug this program unit!!!!!
dear sir,
i tried diligently to find and to debug this tiny program unit,although my observation to the coding rules of the packages ,compilation error still occur.
therefore,kindly i'm asking you sir to learn me how to correct it.
thank you.
create or replace package test_pack is
type emp_table_type is table of emp.sal%type
index by binary_integer;
emp_list emp_table_type;
function test_sal
(v_sal in emp.sal%type)
return emp_table_type;
end test_pack;
create or replace package body test_pack is
temp emp.sal%type;
cursor emp_cursor is
select sal from emp;
i number :=1;
j number :=1;
function test_sal
(v_sal in emp.sal%type)
return emp_table_type
is
open emp_cursor;
loop
fetch emp_cursor into temp;
if temp < v_sal then
emp_list(i):=temp;
bms_output.put_line('rowcount i='||emp_cursor%rowcount);
dbms_output.put_line('iterator i='||i);
i:=i+1;
else
dbms_output.put_line('rowcount j='||emp_cursor%rowcount);
dbms_output.put_line('iterator j='||j);
j:=j+1;
end if;
if emp_cursor%notfound then
dbms_output.put_line('cursor closed...');
close emp_cursor;
return emp_list;
exit;
end if;
end loop;
end test_pack;You can use "show err" to show the errors after compilation errors occur:
SQL> create or replace package test_pack is
2 type emp_table_type is table of emp.sal%type index by binary_integer;
3 emp_list emp_table_type;
4 function test_sal(v_sal in emp.sal%type) return emp_table_type;
5 end test_pack;
6 /
Package is aangemaakt.
SQL> create or replace package body test_pack is
2 temp emp.sal%type;
3 cursor emp_cursor is
4 select sal from emp;
5 i number :=1;
6 j number :=1;
7
8 function test_sal
9 (v_sal in emp.sal%type)
10 return emp_table_type
11 is
12 open emp_cursor;
13 loop
14 fetch emp_cursor into temp;
15 if temp < v_sal then
16 emp_list(i):=temp;
17 bms_output.put_line('rowcount i='||emp_cursor%rowcount);
18 dbms_output.put_line('iterator i='||i);
19 i:=i+1;
20 else
21 dbms_output.put_line('rowcount j='||emp_cursor%rowcount);
22 dbms_output.put_line('iterator j='||j);
23 j:=j+1;
24 end if;
25 if emp_cursor%notfound then
26 dbms_output.put_line('cursor closed...');
27 close emp_cursor;
28 return emp_list;
29 exit;
30 end if;
31 end loop;
32 end test_pack;
33 /
Waarschuwing: package-body is aangemaakt met compilatiefouten.
SQL> show err
Fouten voor PACKAGE BODY TEST_PACK:
LINE/COL ERROR
14/7 PLS-00103: Symbool "FETCH" aangetroffen terwijl een van de
volgende werd verwacht:
constant exception <een ID>
<een scheidingsteken-ID tussen dubbele aanhalingstekens>
table LONG_ double ref char time timestamp interval date
binary national character nchar
32/5 PLS-00103: Symbool "TEST_PACK" aangetroffen terwijl een van de
volgende werd verwacht:
;To make your program compile, add a begin and end and fix the typo (in bold):
SQL> create or replace package body test_pack is
2 temp emp.sal%type;
3 cursor emp_cursor is
4 select sal from emp;
5 i number :=1;
6 j number :=1;
7
8 function test_sal
9 (v_sal in emp.sal%type)
10 return emp_table_type
11 is
12 begin
13 open emp_cursor;
14 loop
15 fetch emp_cursor into temp;
16 if temp < v_sal then
17 emp_list(i):=temp;
18 dbms_output.put_line('rowcount i='||emp_cursor%rowcount);
19 dbms_output.put_line('iterator i='||i);
20 i:=i+1;
21 else
22 dbms_output.put_line('rowcount j='||emp_cursor%rowcount);
23 dbms_output.put_line('iterator j='||j);
24 j:=j+1;
25 end if;
26 if emp_cursor%notfound then
27 dbms_output.put_line('cursor closed...');
28 close emp_cursor;
29 return emp_list;
30 exit;
31 end if;
32 end loop;
33 end;
34 end test_pack;
35 /
Package-body is aangemaakt.
SQL> declare
2 t test_pack.emp_table_type;
3 begin
4 t := test_pack.test_sal(2000);
5 for i in 1..t.count
6 loop
7 dbms_output.put_line(t(i));
8 end loop;
9 end;
10 /
rowcount i=1
iterator i=1
rowcount i=2
iterator i=2
rowcount i=3
iterator i=3
rowcount j=4
iterator j=1
rowcount i=5
iterator i=4
rowcount j=6
iterator j=2
rowcount j=7
iterator j=3
rowcount j=8
iterator j=4
rowcount j=9
iterator j=5
rowcount i=10
iterator i=5
rowcount i=11
iterator i=6
rowcount i=12
iterator i=7
rowcount j=13
iterator j=6
rowcount i=14
iterator i=8
rowcount i=14
iterator i=9
cursor closed...
800
1600
1250
1250
1500
1100
950
1300
1300
PL/SQL-procedure is geslaagd.To fix the bug of the last iteration and put the variables in the sections they belong:
SQL> create or replace package test_pack is
2 type emp_table_type is table of emp.sal%type index by binary_integer;
3 function test_sal(v_sal in emp.sal%type) return emp_table_type;
4 end test_pack;
5 /
Package is aangemaakt.
SQL> create or replace package body test_pack
2 is
3 function test_sal(v_sal in emp.sal%type) return emp_table_type
4 is
5 emp_list emp_table_type;
6 temp emp.sal%type;
7 cursor emp_cursor is select sal from emp;
8 i number :=1;
9 j number :=1;
10 begin
11 open emp_cursor;
12 loop
13 fetch emp_cursor into temp;
14 if emp_cursor%notfound then
15 dbms_output.put_line('cursor closed...');
16 exit;
17 end if;
18 if temp < v_sal then
19 emp_list(i):=temp;
20 dbms_output.put_line('rowcount i='||emp_cursor%rowcount);
21 dbms_output.put_line('iterator i='||i);
22 i:=i+1;
23 else
24 dbms_output.put_line('rowcount j='||emp_cursor%rowcount);
25 dbms_output.put_line('iterator j='||j);
26 j:=j+1;
27 end if;
28 end loop;
29 close emp_cursor;
30 return emp_list;
31 end;
32 end test_pack;
33 /
Package-body is aangemaakt.
SQL> declare
2 t test_pack.emp_table_type;
3 begin
4 t := test_pack.test_sal(2000);
5 for i in 1..t.count
6 loop
7 dbms_output.put_line(t(i));
8 end loop;
9 end;
10 /
rowcount i=1
iterator i=1
rowcount i=2
iterator i=2
rowcount i=3
iterator i=3
rowcount j=4
iterator j=1
rowcount i=5
iterator i=4
rowcount j=6
iterator j=2
rowcount j=7
iterator j=3
rowcount j=8
iterator j=4
rowcount j=9
iterator j=5
rowcount i=10
iterator i=5
rowcount i=11
iterator i=6
rowcount i=12
iterator i=7
rowcount j=13
iterator j=6
rowcount i=14
iterator i=8
cursor closed...
800
1600
1250
1250
1500
1100
950
1300
PL/SQL-procedure is geslaagd.To be really efficient and not care about looping, using counters and dbms_output, and assuming the emp table won't ever be a big table (else use the LIMIT clause):
SQL> create or replace package body test_pack
2 is
3 function test_sal(v_sal in emp.sal%type) return emp_table_type
4 is
5 emp_list emp_table_type;
6 begin
7 select sal bulk collect into emp_list
8 from emp
9 where sal < v_sal
10 ;
11 return emp_list;
12 end;
13 end;
14 /
Package-body is aangemaakt.
SQL> declare
2 t test_pack.emp_table_type;
3 begin
4 t := test_pack.test_sal(2000);
5 for i in 1..t.count
6 loop
7 dbms_output.put_line(t(i));
8 end loop;
9 end;
10 /
800
1600
1250
1250
1500
1100
950
1300
PL/SQL-procedure is geslaagd.Hope it helps.
Regards,
Rob. -
Please help me finish this program
Hi I am currently trying to finish this project with labview...though I have run into some problems. First off here is the explaination of the project.
And lastly, the project, a bicycle dash-o-meter, which will return us to using LabVIEW to produce a program which will take the rotations of a wheel (27" diameter, with a sensor mounted at 6" from the center), and calculate distance, speed, time, ...). We'll use a simulated input of course, but we could interface it to a real bicycle wheel or any wheel or shaft for that matter.
My problem is that we have only been using labview for 2 weeks and it is now due tomorrow. I have a program all drawn up but its not controlled by a blinking led...how to I get a simulated signal to run this. Also how do I get the distance to increase without just changing...for example if I went at 100 km/h for 16 minutes thats roughly 16 km how to I get it to keep that 16 km and then slow down the speed to 50 km/h and get the 16km and hour to increase at the new rate?
I hope some of that made sense. Any help is appriciated.
Here is what I have...P.S. Labview 7.0 is what we have here at the school.
Attachments:
Bike Project.vi 44 KBDan's suggestion is really good.
For your LED to blink, determine logically when you want that to occur.
One way is to change the state of an LED at each revolution, kind of like a switch. At the start, the LED is OFF. When the distance traveled is greater than the circumference, the LED comes ON, and your distance counter is reset to zero. When the distance traveled is again greater than the circum., change the LED again.
Another way is that when the wheel rotates one revolution, turn the LED ON for a set time, like 0.5 seconds. However, at speeds greater than 120RPM, the LED will always be ON.
What you are really doing is counting pulses from the sensor, and the time between them.
If I might make a couple of suggestions for your code, don't hide the STOP button. Also, try to always keep your wiring to flow in a Left-to-Right direction. That will certainly help with understanding what everything does, and will make troubleshooting a great deal easier.
B-) -
Please help me on this program
I wrote a binary search tree to store the name, birthday, and phone number. But everytime I tried to insert some values, I got the java.lang.nullpoint.exception: Please check out the program:
BinaryNode:
public class BinaryNode{
protected String name, birth, phone;
protected BinaryNode parent, left, right;
public BinaryNode(){
name = null;
birth = null;
phone = null;
parent = null;
left = null;
right = null;
public BinaryNode(String n, String b, String p, BinaryNode pa, BinaryNode l, BinaryNode r){
name = n;
birth = b;
phone = p;
parent = pa;
left = l;
right = r;
public void setParent(BinaryNode p){
parent = p;
public void setLeft(BinaryNode l){
left = l;
public void setRight(BinaryNode r){
right = r;
public BinaryNode getLeft(){
return left;
public BinaryNode getRight(){
return right;
public BinaryNode getParent(){
return parent;
public String getName(){
return name;
public String getBirth(){
return birth;
public String getPhone(){
return phone;
public void setData(String n, String b, String p){
name = n;
birth = b;
phone = p;
Binarytree:
import java.io.*;
import java.util.*;
public class Binarytree{
protected BinaryNode second;
protected BinaryNode head;
protected BinaryNode left;
protected BinaryNode right;
protected int number;
public Binarytree(){
head = null;
number = 0;
public boolean isEmpty(){
if (number == 0)
return true;
else
return false;
public int size(){
return number;
public void insertName(String n, String d, String m){
head = new BinaryNode(n, d, m, head, left, right);
second = null;
while (head != null) {
second = head;
if (n.compareTo(head.getName()) < 0)
head = head.getLeft();
else
head = head.getRight();
if (second == null){
head.setData(n, d, m);
if (n.compareTo(second.getName()) < 0)
second.getLeft().setData(n, d, m);
else
second.getRight().setData(n, d, m);
number++;
public void insertBirth(String n, String d, String m){
head = new BinaryNode(n, d, m, head, left, right);
second = null;
while (head != null) {
second = head;
if (d.compareTo(head.getName()) < 0)
head = head.getLeft();
else
head = head.getRight();
if (second == null){
head.setData(n, d, m);
if (d.compareTo(second.getName()) < 0)
second.getLeft().setData(n, d, m);
else
second.getRight().setData(n, d, m);
number++;
public BinaryNode searchName(String name){
BinaryNode n = head;
if(n != null || name == n.getName())
return n;
if(n != null || name != n.getName())
return null;
if(name.compareTo(n.getName()) < 0){
n = n.getLeft();
return searchName(name);
else{
n = n.getRight();
return searchName(name);
public BinaryNode searchBirth(String birth){
BinaryNode n = head;
if(n != null || birth == n.getBirth())
return n;
if(n != null || birth != n.getBirth())
return null;
if(birth.compareTo(n.getBirth()) < 0){
n = n.getLeft();
return searchBirth(birth);
else{
n = n.getRight();
return searchBirth(birth);
public BinaryNode treeMin(BinaryNode n){
n = head;
while(n.getLeft() != null){
n = n.getLeft();
return n;
public BinaryNode treeSuc(String name){
BinaryNode n = head;
BinaryNode y;
BinaryNode x;
x = searchBirth(name);
if(x.getRight() != null){
return treeMin(x.getRight());
else{
y = x.getParent();
while( y != null && x == y.getRight()){
x = y;
y = y.getParent();
return y;
public String removeName(String name){
BinaryNode n = head;
BinaryNode x, y, t;
x = searchBirth(name);
if (x.getLeft() == null || x.getRight() == null)
y = x;
else
y = treeSuc(name);
if (y.getLeft() != null)
t = y.getLeft();
else
t = y.getRight();
if (t != null)
t.setParent(y.getParent());
if (y.getParent() == null)
head = t;
else if (y == y.getParent().getLeft())
y.getParent().setLeft(t);
else
y.getParent().setRight(t);
return y.getName();
public void print(BinaryNode n){
System.out.println(n.getName() + ", " + n.getBirth() + ", " + n.getPhone());
System.out.println("");
public void inorderPrint(BinaryNode n){
n = head;
if(n == null)
return;
inorderPrint(n.getLeft());
print(n);
inorderPrint(n.getRight());
public void listByName(){
BinaryNode n = head;
inorderPrint(n);
public void listByBirth(){
head = null;
readFileByBirth();
BinaryNode n = head;
inorderPrint(n);
public void inorderTrave(BinaryNode n){
n = head;
inorderTrave(n.getLeft());
inorderTrave(n.getRight());
public void readFileByName() {
try {
BufferedReader in = new BufferedReader(new FileReader("myFile.dat"));
String n = "s", d = "s", p = "s";
int count = 1;
while(in.readLine() != null){
count++;
BufferedReader in1 = new BufferedReader(new FileReader("myFile.dat"));
for (int i = 0; i < count / 3; i++){
n = in1.readLine();
d = in1.readLine();
p = in1.readLine();
insertName(n, d, p);
in.close();
} catch (IOException e) {
public void readFileByBirth() {
try {
BufferedReader in = new BufferedReader(new FileReader("myFile.dat"));
String n = "s", d = "s", p = "s";
int count = 1;
while(in.readLine() != null){
count++;
BufferedReader in1 = new BufferedReader(new FileReader("myFile.dat"));
for (int i = 0; i < count / 3; i++){
n = in1.readLine();
d = in1.readLine();
p = in1.readLine();
insertBirth(n, d, p);
in.close();
} catch (IOException e) {
public void writeText(){
try {
BufferedWriter out = new BufferedWriter(new FileWriter("myFile.dat"));
BinaryNode n = head;
inorderTrave(n);
out.write(n.getName());
out.newLine();
out.write(n.getBirth());
out.newLine();
out.write(n.getPhone());
out.close();
} catch (IOException e) {
public String getDate(){
Date date = new Date();
String dt = null, m = null, y = null;
String computerDate = null;
int d = date.getMonth() + 1;
if (d == 1)
m = "Jan";
else if (d == 2)
m = "Feb";
else if (d == 3)
m = "March";
else if (d == 4)
m = "Apr";
else if (d == 5)
m = "May";
else if (d == 6)
m = "Jun";
else if (d == 7)
m = "Jul";
else if (d == 8)
m = "Aug";
else if (d == 9)
m = "Sep";
else if (d == 10)
m = "Oct";
else if (d == 11)
m = "Nov";
else
m = "Dec";
dt = ""+date.getDate();
computerDate = dt + " " + m + ". " + 2006;
return computerDate;
test:
import java.io.*;
import java.util.*;
public class test{
public static void main(String[] args) throws IOException {
String n = null, d = null, m = null;
int position = 0;
int option = 0;
int doMore;
Binarytree list = new Binarytree();
while(option != 9){
System.out.println("Enter your options:");
System.out.println("0. Adding More Friends");
System.out.println("1. Remove A Friend by His List Index");
System.out.println("2. List Your Friends by name");
System.out.println("3. List Your Friends by DOB");
System.out.println("4. Save");
System.out.println("5. Load");
System.out.println("6. Search Friends by Their Name");
System.out.println("7. Search Friends by Their Birthdays");
System.out.println("8. Check Birthday");
System.out.println("9. Exit");
option = getInt();
if (option == 0){
doMore = -1;
while(doMore != 0){
System.out.println("Enter The Last and First Name of your friend:");
n = getString();
System.out.println("Enter The Date of your friend's Birthday:");
d = getString();
System.out.println("Enter Your Friend's Phone Number:");
m = getString();
System.out.println("Adding More? 1 for Yes Or 0 for No:");
doMore = getInt();
list.insertName(n, d, m);
doMore = -1;
n = null;
d = null;
m = null;
else if (option == 2){
list.listByName();
else if (option == 3){
list.listByBirth();
else if (option == 6){
doMore = -1;
while(doMore != 0){
System.out.println("Enter The Name of your friend:");
n = getString();
list.searchName(n);
System.out.println("Searching More? 1 for Yes Or 0 for No:");
doMore = getInt();
doMore = -1;
n = null;
d = null;
m = null;
else if (option == 7){
doMore = -1;
while(doMore != 0){
System.out.println("Enter Your friend's Birthday:");
d = getString();
list.searchBirth(d);
System.out.println("Searching More? 1 for Yes Or 0 for No:");
doMore = getInt();
doMore = -1;
n = null;
d = null;
m = null;
else if (option == 8){
String s = list.getDate();
doMore = -1;
while(doMore != 0){
list.searchBirth(s);
System.out.println("Searching More? 1 for Yes Or 0 for No:");
doMore = getInt();
doMore = -1;
n = null;
d = null;
m = null;
else if (option == 5){
list.readFileByName();
else if (option == 4){
list.writeText();
else if (option == 1){
System.out.println("Enter List Index your friend:");
String z = getString();
System.out.println("Removed Friend is ");
list.removeName(z);
static String getString() throws IOException{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String s = br.readLine();
return s;
static int getInt() throws IOException{
int x;
BufferedReader reader = new BufferedReader (new InputStreamReader(System.in),1);
x = Integer.parseInt(reader.readLine());
return x;
}I wrote a binary search tree to store the name, birthday, and phone
number. But everytime I tried to insert some values, I got the
java.lang.nullpoint.exception: Please check out the program:Well, you're using something that's not defined, obviously. The error message will tell you what line it is one. Go to that line and note the variables on it, then trace your code backwards until you figure out why one of them hasn't been defined.
But, as was said, nobody is going to read that much unformatted code, especially when we don't even have the first clue as to where the problem is. -
Please help me understand this program
REPORT zmmrus160 NO STANDARD PAGE HEADING
LINE-SIZE 255 LINE-COUNT 65(3) MESSAGE-
INCLUDE zmmrus160top.
INCLUDE <icon>.
INITIALIZATION.
PERFORM initialize_variant.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM f4_for_variant.
AT SELECTION-SCREEN ON p_vari.
PERFORM validate_user_selection.
PERFORM check_variant.
AT SELECTION-SCREEN.
AT SELECTION-SCREEN ON p_wrkst.
PERFORM authority_check.
START OF SELECTION ****
START-OF-SELECTION.
PERFORM get_materials.
PERFORM get_tlmap.
PERFORM validate_tlmap_mapl.
PERFORM build_events USING gt_events[].
PERFORM build_comment USING gt_list_top_of_page[].
PERFORM build_sp_group USING gt_sp_group[].
PERFORM build_sort.
PERFORM build_layout USING gs_layout.
PERFORM build_fieldcat CHANGING gt_fieldcat[].
END-OF-SELECTION.
PERFORM write_report_alv. "write report
*& Form initialize_variant
text
FORM initialize_variant .
CLEAR gs_variant.
gs_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = 'A'
CHANGING
cs_variant = gs_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc EQ 0.
p_vari = gs_variant-variant.
ENDIF.
ENDFORM. " INITIALIZE_VARIANT
*& Form f4_for_variant
text
FORM f4_for_variant .
DATA: lv_exit.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = gs_variant
i_save = 'A'
IMPORTING
e_exit = lv_exit
es_variant = gs_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF lv_exit = space.
p_vari = gs_variant-variant.
ENDIF.
ENDIF.
gs_variant-report = sy-repid.
ENDFORM. "f4_for_variant
*& Form check_variant
text
FORM check_variant .
IF NOT p_vari IS INITIAL.
MOVE p_vari TO gs_variant-variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = 'A'
CHANGING
cs_variant = gs_variant
EXCEPTIONS
wrong_input = 1
not_found = 2
program_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM. " check_variant
FORM GET_MATERIALS *
this form creates MATTAB
FORM get_materials.
*get materials for the report
SELECT matnr spart matkl prdha meins wrkst extwg groes normt
FROM mara
INTO TABLE gt_mara
WHERE matnr IN p_matnr
AND spart IN p_spart
AND matkl IN p_matkl
AND prdha IN p_prdha
AND wrkst IN p_wrkst
AND extwg IN p_extwg
AND groes IN p_groes
AND normt IN p_normt
AND lvorm = space.
CHECK sy-subrc IS INITIAL.
SELECT matnr werks
FROM marc
INTO TABLE gt_marc
FOR ALL ENTRIES IN gt_mara
WHERE matnr = gt_mara-matnr
AND werks IN p_werks
AND lvorm = space
AND mmsta IN (space, '01').
CHECK sy-subrc IS INITIAL.
SELECT matnr werks lgort
FROM mard
INTO TABLE gt_mard
FOR ALL ENTRIES IN gt_marc
WHERE matnr = gt_marc-matnr
AND werks = gt_marc-werks
AND lgort IN p_lgort
AND lvorm = space.
CHECK sy-subrc IS INITIAL.
SORT gt_mara BY matnr.
SORT gt_marc BY matnr werks.
SORT gt_mard BY matnr werks lgort.
ENDFORM. "GET_MATERIALS
*& Form get_tlmap
text
FORM get_tlmap.
DATA: BEGIN OF lt_tlmap OCCURS 0.
INCLUDE STRUCTURE zmmtlmap.
DATA: END OF lt_tlmap.
DATA: lv_fetflag LIKE zmmtlmap-fetflag.
*get task list map for the materials
LOOP AT gt_mara.
READ TABLE gt_marc WITH KEY matnr = gt_mara-matnr
BINARY SEARCH.
CHECK sy-subrc IS INITIAL.
LOOP AT gt_marc FROM sy-tabix.
IF gt_marc-matnr <> gt_mara-matnr.
EXIT.
ENDIF.
IF gt_mara-normt CS 'FET'.
lv_fetflag = 'X'.
ELSE.
CLEAR lv_fetflag.
ENDIF.
*select from ZMMTLMAP...
SELECT * FROM zmmtlmap
INTO TABLE lt_tlmap
WHERE werks = gt_marc-werks
AND spart = gt_mara-spart
AND matkl = gt_mara-matkl
AND wrkst = gt_mara-wrkst
AND groes = gt_mara-groes
AND fetflag = lv_fetflag
AND prdha = gt_mara-prdha.
IF NOT sy-subrc IS INITIAL.
*...sometimes seed size (GROES) can be blank
SELECT * FROM zmmtlmap
INTO TABLE lt_tlmap
WHERE werks = gt_marc-werks
AND spart = gt_mara-spart
AND matkl = gt_mara-matkl
AND wrkst = gt_mara-wrkst
AND groes = space
AND fetflag = lv_fetflag
AND prdha = gt_mara-prdha.
ENDIF.
IF NOT sy-subrc IS INITIAL.
*...look for blank PRDHA
SELECT * FROM zmmtlmap
INTO TABLE lt_tlmap
WHERE werks = gt_marc-werks
AND spart = gt_mara-spart
AND matkl = gt_mara-matkl
AND wrkst = gt_mara-wrkst
AND groes = gt_mara-groes
AND fetflag = lv_fetflag
AND prdha = space.
ENDIF.
IF NOT sy-subrc IS INITIAL.
*...look for blank PRDHA and GROES
SELECT * FROM zmmtlmap
INTO TABLE lt_tlmap
WHERE werks = gt_marc-werks
AND spart = gt_mara-spart
AND matkl = gt_mara-matkl
AND wrkst = gt_mara-wrkst
AND groes = space
AND fetflag = lv_fetflag
AND prdha = space.
ENDIF.
CHECK sy-subrc IS INITIAL.
LOOP AT lt_tlmap.
CLEAR gt_tlmap.
gt_tlmap-matnr = gt_mara-matnr.
MOVE-CORRESPONDING lt_tlmap TO gt_tlmap.
APPEND gt_tlmap.
ENDLOOP. "tlmap
ENDLOOP. "marc
ENDLOOP. "mara
ENDFORM. "get_tlmap
*& Form validate_tlmap_mapl
text
FORM validate_tlmap_mapl .
DATA: lv_plnnr.
LOOP AT gt_tlmap.
SELECT SINGLE plnnr
FROM mapl
INTO lv_plnnr
WHERE matnr = gt_tlmap-matnr
AND werks = gt_tlmap-werks
AND plnty = gt_tlmap-plnty
AND plnnr = gt_tlmap-plnnr
AND plnal = gt_tlmap-plnal
AND loekz = space.
IF sy-subrc IS INITIAL.
gt_tlmap-errflag = 'A'. "already assigned
gt_tlmap-notes = 'Already assigned'.
gt_tlmap-linecolor = 'C31'.
ENDIF.
MODIFY gt_tlmap.
ENDLOOP.
ENDFORM. " validate_tlmap_mapl
*& Form build_fieldcat
text
FORM build_fieldcat CHANGING lt_fieldcat TYPE slis_t_fieldcat_alv.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'GT_TLMAP'
i_inclname = 'ZMMRUS160TOP'
CHANGING
ct_fieldcat = lt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc NE 0.
EXIT.
ENDIF.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
LOOP AT lt_fieldcat INTO ls_fieldcat.
*column headings, output lengths, field positions etc
CASE ls_fieldcat-fieldname.
WHEN 'ERRFLAG'.
ls_fieldcat-seltext_s = 'Error!'.
ls_fieldcat-seltext_m = 'Error!'.
ls_fieldcat-seltext_l = 'Error!'.
ls_fieldcat-reptext_ddic = 'Error!'.
WHEN 'NOTES'.
ls_fieldcat-seltext_s = 'Notes'.
ls_fieldcat-seltext_m = 'Notes'.
ls_fieldcat-seltext_l = 'Notes'.
ls_fieldcat-reptext_ddic = 'Notes'.
ENDCASE.
MODIFY lt_fieldcat FROM ls_fieldcat.
ENDLOOP.
ENDFORM. "build_fieldcat
*& Form build_layout
text
FORM build_layout USING ls_layout TYPE slis_layout_alv.
ls_layout-info_fieldname = 'LINECOLOR'.
LS_LAYOUT-BOX_FIELDNAME = 'BOX'.
LS_LAYOUT-LIGHTS_FIELDNAME = 'LIGHTS'.
ls_layout-zebra = 'X'.
LS_LAYOUT-NO_VLINE = 'X'.
ls_layout-no_unit_splitting = 'X'.
ls_layout-cell_merge = space.
ls_layout-totals_only = 'X'.
ls_layout-colwidth_optimize = 'X'.
ls_layout-no_sumchoice = 'X'.
ls_layout-no_subchoice = 'X'.
ls_layout-box_fieldname = 'CHECKBOX'.
ls_layout-box_tabname = 'GT_TLMAP'.
ls_layout-no_totalline = 'X'.
ls_layout-coltab_fieldname = 'CELLCOLORS'.
ENDFORM. "BUILD_LAYOUT
*& Form build_sort
text
FORM build_sort.
DATA: is_sort TYPE slis_sortinfo_alv.
REFRESH gt_sort.
CLEAR is_sort.
is_sort-spos = 1.
is_sort-fieldname = 'MATNR'.
is_sort-up = 'X'.
APPEND is_sort TO gt_sort.
CLEAR is_sort.
is_sort-spos = 2.
is_sort-fieldname = 'WERKS'.
is_sort-up = 'X'.
APPEND is_sort TO gt_sort.
CLEAR is_sort.
is_sort-spos = 3.
is_sort-fieldname = 'LGORT'.
is_sort-up = 'X'.
APPEND is_sort TO gt_sort.
ENDFORM. " build_sort
*& Form build_sp_group
text
FORM build_sp_group USING us_t_sp_group TYPE slis_t_sp_group_alv.
DATA: ls_sp_group TYPE slis_sp_group_alv.
CLEAR ls_sp_group.
ls_sp_group-sp_group = 'A'.
ls_sp_group-text = 'Key Fields'.
APPEND ls_sp_group TO us_t_sp_group.
CLEAR ls_sp_group.
ls_sp_group-sp_group = 'B'.
ls_sp_group-text = 'Forecast Quantities'.
APPEND ls_sp_group TO us_t_sp_group.
CLEAR ls_sp_group.
ls_sp_group-sp_group = 'C'.
ls_sp_group-text = 'Short Position'.
APPEND ls_sp_group TO us_t_sp_group.
RN MOD
CLEAR ls_sp_group.
ls_sp_group-sp_group = 'C'.
ls_sp_group-text = 'Ship Position'.
APPEND ls_sp_group TO us_t_sp_group.
CLEAR ls_sp_group.
ls_sp_group-sp_group = 'C'.
ls_sp_group-text = 'Shippable Qty'.
APPEND ls_sp_group TO us_t_sp_group.
CLEAR ls_sp_group.
ls_sp_group-sp_group = 'C'.
ls_sp_group-text = 'Rebag Qty'.
APPEND ls_sp_group TO us_t_sp_group.
CLEAR ls_sp_group.
ls_sp_group-sp_group = 'C'.
ls_sp_group-text = 'Retag Shippable'.
APPEND ls_sp_group TO us_t_sp_group.
ENDFORM. "build_sp_group
*& Form pf_status_set
text
-->EXTAB text
FORM pf_status_set USING extab TYPE slis_t_extab.
SET PF-STATUS 'ALV_STATUS' EXCLUDING extab.
ENDFORM. "PF_STATUS_SET
*& Form build_events
text
-->US_T_EVENTStext
FORM build_events USING us_t_events TYPE slis_t_event.
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = us_t_events.
READ TABLE us_t_events WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE gc_form_top_of_page TO ls_event-form.
APPEND ls_event TO us_t_events.
ENDIF.
READ TABLE us_t_events WITH KEY name = slis_ev_user_command
INTO ls_event.
IF sy-subrc = 0.
MOVE gc_form_user_command TO ls_event-form.
APPEND ls_event TO us_t_events.
ENDIF.
ENDFORM. "build_EVENTs
*& Form build_comment
text
FORM build_comment USING us_t_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader.
DATA: tmp_char(10).
ls_line-typ = 'H'.
ls_line-info = text-h01.
APPEND ls_line TO us_t_top_of_page.
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-key = 'User/System:'.
CONCATENATE sy-uname sy-sysid sy-mandt
INTO ls_line-info SEPARATED BY space.
APPEND ls_line TO us_t_top_of_page.
ls_line-key = 'Date/Time:'.
WRITE sy-datlo TO ls_line-info.
WRITE sy-timlo TO tmp_char.
CONCATENATE ls_line-info tmp_char sy-zonlo
INTO ls_line-info SEPARATED BY space.
APPEND ls_line TO us_t_top_of_page.
ENDFORM. " build_COMMENT
*& Form top_of_page
text
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = gt_list_top_of_page.
ENDFORM. "TOP_OF_PAGE
*& Form write_report_alv
text
--> p1 text
<-- p2 text
FORM write_report_alv .
g_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_pf_status_set = 'PF_STATUS_SET'
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
it_sort = gt_sort[]
i_save = 'A'
it_events = gt_events[]
TABLES
t_outtab = gt_tlmap
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "write_report_alv
*& Form user_command
text
FORM user_command USING ucomm TYPE sy-ucomm selfield TYPE slis_selfield.
CASE sy-ucomm.
WHEN 'PROCESS'.
PERFORM process_materials.
selfield-refresh = 'X'.
ENDCASE.
ENDFORM. "USER_COMMAND
*& Form process_materials
text
FORM process_materials .
REFRESH gt_taskl.
LOOP AT gt_tlmap WHERE checkbox = 'X'.
CHECK gt_tlmap-errflag IS INITIAL.
CLEAR gt_taskl.
MOVE-CORRESPONDING gt_tlmap TO gt_taskl.
APPEND gt_taskl.
ENDLOOP.
SORT gt_taskl BY werks plnty plnnr matnr.
PERFORM bdc_assign_to_tasklists.
PERFORM bapi_assign_to_tasklists.
LOOP AT gt_tlmap.
READ TABLE gt_taskl WITH KEY werks = gt_tlmap-werks
plnty = gt_tlmap-plnty
plnnr = gt_tlmap-plnnr
matnr = gt_tlmap-matnr
BINARY SEARCH.
CHECK sy-subrc IS INITIAL.
CLEAR gt_tlmap-checkbox.
READ TABLE gt_errtab WITH KEY plnty = gt_tlmap-plnty
plnnr = gt_tlmap-plnnr
BINARY SEARCH.
IF sy-subrc IS INITIAL.
gt_tlmap-errflag = 'X'.
gt_tlmap-notes = gt_errtab-notes.
ELSE.
gt_tlmap-errflag = 'P'.
gt_tlmap-notes = 'Processed'.
ENDIF.
IF gt_tlmap-errflag = 'X'.
gt_tlmap-linecolor = 'C61'.
ELSEIF gt_tlmap-errflag = 'P'.
gt_tlmap-linecolor = 'C51'.
ENDIF.
MODIFY gt_tlmap.
ENDLOOP.
ENDFORM. " process_materials
*& Form bdc_assign_to_tasklists
text
FORM bdc_assign_to_tasklists .
LOOP AT gt_taskl.
AT NEW plnty.
IF gt_taskl-plnty = c_plnty_rout.
gv_scr_init = '1010'.
gv_scr_assn = '1010'.
gv_tran = 'CA02'.
ELSEIF gt_taskl-plnty = c_plnty_insp.
gv_scr_init = '8010'.
gv_scr_assn = '4010'.
gv_tran = 'QP02'.
ENDIF.
ENDAT.
AT NEW plnnr.
REFRESH bdctab.
PERFORM bdc_dynpro USING: 'X' 'SAPLCPDI' gv_scr_init,
' ' 'RC27M-WERKS' space,
' ' 'RC27M-MATNR' space,
' ' 'RC271-PLNNR' gt_taskl-plnnr,
' ' 'RC271-PLNAL' space,
' ' 'BDC_OKCODE' '=ALUE'.
PERFORM bdc_dynpro USING: 'X' 'SAPLCPDI' '1200',
' ' 'BDC_OKCODE' '=MTUE'.
PERFORM bdc_dynpro USING: 'X' 'SAPLCZDI' gv_scr_assn,
' ' 'BDC_OKCODE' 'P++'.
ENDAT.
PERFORM bdc_dynpro USING: 'X' 'SAPLCZDI' gv_scr_assn,
' ' 'BDC_OKCODE' 'P+'.
SHIFT gt_taskl-matnr LEFT DELETING LEADING '0'.
PERFORM bdc_dynpro USING: 'X' 'SAPLCZDI' gv_scr_assn,
' ' 'BDC_OKCODE' 'P+',
' ' 'MAPL-PLNAL(2)' gt_taskl-plnal,
' ' 'MAPL-MATNR(2)' gt_taskl-matnr,
' ' 'MAPL-WERKS(2)' gt_taskl-werks.
AT END OF plnnr.
PERFORM bdc_dynpro USING: 'X' 'SAPLCZDI' gv_scr_assn,
' ' 'BDC_OKCODE' '/00'.
PERFORM bdc_dynpro USING: 'X' 'SAPLCPDI' '1200',
' ' 'BDC_OKCODE' '=BU'.
PERFORM call_tran USING gv_tran.
IF NOT bdcrc IS INITIAL.
PERFORM store_error.
ENDIF.
ENDAT.
ENDLOOP.
SORT gt_errtab BY plnty plnnr.
ENDFORM. "bdc_assign_to_tasklists
*& Form bdc_dynpro
text
FORM bdc_dynpro USING dynbegin name value.
CLEAR bdctab.
IF dynbegin EQ charx.
MOVE: name TO bdctab-program,
value TO bdctab-dynpro,
charx TO bdctab-dynbegin.
ELSE.
MOVE: name TO bdctab-fnam,
value TO bdctab-fval.
ENDIF.
APPEND bdctab.
ENDFORM. " BDC_DYNPRO
*& Form call_tran
text
FORM call_tran USING tcode.
CLEAR bdcmsg. REFRESH bdcmsg.
CALL TRANSACTION tcode
USING bdctab
MODE bdcmode
UPDATE bdcupdt
MESSAGES INTO bdcmsg.
bdcrc = sy-subrc.
ENDFORM. " CALL_TRAN
*& Form bapi_assign_to_tasklists
FORM bapi_assign_to_tasklists .
DATA: save_di LIKE save_di.
DATA: BEGIN OF mapl_di OCCURS 0.
INCLUDE STRUCTURE mapl_di.
DATA: END OF mapl_di.
DATA: error_di_exp LIKE error_di.
DATA: plnnr_exp LIKE rc271-plnnr.
DATA: BEGIN OF error_di_tab OCCURS 0.
INCLUDE STRUCTURE error_di.
DATA: END OF error_di_tab.
DATA: BEGIN OF errtab OCCURS 0.
INCLUDE STRUCTURE cmfmsg.
DATA: END OF errtab.
DATA: BEGIN OF rcuob1 OCCURS 0.
INCLUDE STRUCTURE rcuob1.
DATA: END OF rcuob1.
DATA: BEGIN OF obj_nfield OCCURS 0.
INCLUDE STRUCTURE obj_nfield.
DATA: END OF obj_nfield.
DATA: BEGIN OF rcuob1_ex OCCURS 0.
INCLUDE STRUCTURE rcuob1_ex.
DATA: END OF rcuob1_ex.
DATA: BEGIN OF rcuob2 OCCURS 0.
INCLUDE STRUCTURE rcuob2.
DATA: END OF rcuob2.
relevant ones ---
DATA: rc271_ex LIKE rc271_ex.
DATA: BEGIN OF mapl_di_ex OCCURS 0.
INCLUDE STRUCTURE mapl_di_ex.
DATA: END OF mapl_di_ex.
relevant ones ---
DATA: BEGIN OF plko_di_ex OCCURS 0.
INCLUDE STRUCTURE plko_di_ex.
DATA: END OF plko_di_ex.
DATA: BEGIN OF plpo_di_ex OCCURS 0.
INCLUDE STRUCTURE plpo_di_ex.
DATA: END OF plpo_di_ex.
DATA: BEGIN OF plfl_di_ex OCCURS 0.
INCLUDE STRUCTURE plfl_di_ex.
DATA: END OF plfl_di_ex.
DATA: BEGIN OF plmz_di_ex OCCURS 0.
INCLUDE STRUCTURE plmz_di_ex.
DATA: END OF plmz_di_ex.
DATA: BEGIN OF plfh_di_ex OCCURS 0.
INCLUDE STRUCTURE plfh_di_ex.
DATA: END OF plfh_di_ex.
DATA: BEGIN OF txt_obj_ex OCCURS 0.
INCLUDE STRUCTURE txt_obj_ex.
DATA: END OF txt_obj_ex.
DATA: BEGIN OF txt_di_tab OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF txt_di_tab.
LOOP AT gt_taskl.
*XXX when does QP02 come in - test that scenario
AT NEW plnty.
IF gt_taskl-plnty = c_plnty_rout.
gv_scr_init = '1010'.
gv_scr_assn = '1010'.
gv_tran = 'CA02'.
ELSEIF gt_taskl-plnty = c_plnty_insp.
gv_scr_init = '8010'.
gv_scr_assn = '4010'.
gv_tran = 'QP02'.
ENDIF.
ENDAT.
rc271_ex-tcode = gv_tran.
rc271_ex-werks = gt_taskl-werks.
rc271_ex-plnnr = gt_taskl-plnnr.
rc271_ex-plnal = gt_taskl-plnal.
rc271_ex-sttag = sy-datum.
WRITE sy-datum TO rc271_ex-sttag MM/DD/YYYY.
save_di-syn_save = 'X'.
mapl_di_ex-matnr = gt_taskl-matnr.
mapl_di_ex-werks = gt_taskl-werks.
mapl_di_ex-plnal = gt_taskl-plnal.
mapl_di_ex-acttyp = 'H'.
APPEND mapl_di_ex.
CALL FUNCTION 'CP_BD_DIRECT_INPUT_PLAN_EXT'
EXPORTING
rc271_ex_imp = rc271_ex
RC27M_EX_IMP = ''
save_di_imp = save_di
IMPORTING
error_di_exp = error_di_exp
plnnr_exp = plnnr_exp
TABLES
plko_di_ex_tab = plko_di_ex
mapl_di_ex_tab = mapl_di_ex
plpo_di_ex_tab = plpo_di_ex
plfl_di_ex_tab = plfl_di_ex
plmz_di_ex_tab = plmz_di_ex
plfh_di_ex_tab = plfh_di_ex
text_obj_di_ex_tab = txt_obj_ex
text_di_tab = txt_di_tab
knowl_alloc_obj_di_ex_tab = rcuob1_ex
knowl_alloc_di_ex_tab = rcuob2
obj_null_field_tab = obj_nfield
error_plan_di_tab = error_di_tab
error_plan_tab = errtab.
READ TABLE errtab INDEX 1.
IF errtab-msgty = 'E'.
gt_errtab-plnty = gt_taskl-plnty.
gt_errtab-plnnr = gt_taskl-plnnr.
DATA: msgtxt(250).
SELECT SINGLE text FROM t100
INTO msgtxt
WHERE sprsl = 'E'
AND arbgb = errtab-arbgb
AND msgnr = errtab-msgnr.
IF NOT sy-subrc IS INITIAL.
gt_errtab-notes = errtab-msgv1.
ELSE.
REPLACE '&' WITH errtab-msgv1 INTO gt_errtab-notes.
CONDENSE gt_errtab-notes.
REPLACE '&' WITH errtab-msgv2 INTO gt_errtab-notes.
CONDENSE gt_errtab-notes.
REPLACE '&' WITH errtab-msgv3 INTO gt_errtab-notes.
CONDENSE gt_errtab-notes.
REPLACE '&' WITH errtab-msgv4 INTO gt_errtab-notes.
CONDENSE gt_errtab-notes.
ENDIF.
APPEND gt_errtab.
ENDIF.
ENDLOOP.
SORT gt_errtab BY plnty plnnr.
ENDFORM. " bapi_assign_to_tasklists
*& Form store_error
FORM store_error .
CLEAR gt_errtab.
gt_errtab-plnty = gt_taskl-plnty.
gt_errtab-plnnr = gt_taskl-plnnr.
READ TABLE bdcmsg WITH KEY msgtyp = 'E'.
PERFORM get_message_text USING bdcmsg
CHANGING gt_errtab-notes.
APPEND gt_errtab.
ENDFORM. " store_error
*& Form get_message_text
FORM get_message_text USING us_bdcmsg STRUCTURE bdcmsgcoll
CHANGING ch_msgtxt.
DATA: msgtxt(250).
SELECT SINGLE text FROM t100
INTO msgtxt
WHERE sprsl = us_bdcmsg-msgspra
AND arbgb = us_bdcmsg-msgid
AND msgnr = us_bdcmsg-msgnr.
IF NOT sy-subrc IS INITIAL.
msgtxt = us_bdcmsg-msgv1.
ELSE.
REPLACE '&' WITH us_bdcmsg-msgv1 INTO msgtxt.
CONDENSE msgtxt.
REPLACE '&' WITH us_bdcmsg-msgv2 INTO msgtxt.
CONDENSE msgtxt.
REPLACE '&' WITH us_bdcmsg-msgv3 INTO msgtxt.
CONDENSE msgtxt.
REPLACE '&' WITH us_bdcmsg-msgv4 INTO msgtxt.
CONDENSE msgtxt.
ENDIF.
ch_msgtxt = msgtxt.
ENDFORM. "GET_MESSAGE_TEXTThanks for the reply..I guess I was topo vague is asking the previous question.
For the same program.The program is using direct input method to update the routing of the material i.e CA02. I want to know will it work for inspection as well i.e QP02.If it can work what modification will i have to make here in this funtion module.
If this does not work, is there any direct input method to do the inspection plan for materials.
The name of the function module is CP_BD_DIRECT_INPUT_PLAN_EXT.
Thanks in adnace
deepak -
Please help me understand this program's limit of use?
If I have an adobe connect account, is a form on a formscentral url able to be edited in adobe connect? If the program designed to facilitate online conferences doesn't interface with a conferecne registration template program ran by the same company, market under the same brand as adobe, how can people on opposite sides of firewalls limited by software going to edit products; and use this? Administrators control new program downloads of all new programs, which means no forms central for my partner, even though adobe connect is available there, so how do we share adobe to adobe to make this service all most as cool as printkey?
Seriously an adobe product fan (today is testing my confidence in adobe),
Tiffani the girl with a form she can't use and a deadline that's too close to start over!Thanks for the reply..I guess I was topo vague is asking the previous question.
For the same program.The program is using direct input method to update the routing of the material i.e CA02. I want to know will it work for inspection as well i.e QP02.If it can work what modification will i have to make here in this funtion module.
If this does not work, is there any direct input method to do the inspection plan for materials.
The name of the function module is CP_BD_DIRECT_INPUT_PLAN_EXT.
Thanks in adnace
deepak -
Please help me tune this program,
Hi.
I have a item master data table and a transaction table.
For a given criteria I have to find items from master data table which do no exits in transaction table.
I have listed my flow below, can you please advice if there is any other optimal way of doing it.
1. For the given criteria read items from master data table into internal table 1. Sort the internal table 1.
2. For the given criteria read items from transaction table into internal table 2. Sort and remove duplicates from the internal table 2.
3. Loop at internal table 1, and check if item exists in internal table 2. Append items not in internal table 2 into another internal table 3.
At the end internal table 3 will have the items I am interested in. I can sort and use binary search addition, but is there any other efficient way of doing this task.
Thank you,
CDDon't use standard tables !!!!!!! They are o.k. in old coding in new coding you should
use only sorted and hashed tables and performance works automatically !!!
Forget about sorting and deleting duplicates !
> remove duplicates from the internal table 2.
use a hashed table with a unique key and collect you entries in the hash table,
Use sorted tables if the key is non-unique, or if the need also parts of the key!
Use hashed tables if the key must be unique.
Even for the append it is possible to APPEND into a sorted table, the records must come in a sort
order, i.e. if they come from a sorted table then it is o.k.
What I write is not imagination but the only really commendable way of handling internal tables.
Siegfried -
PLEASE CAN SOMEOME HELP ME INSTALL THIS PROGRAM????
PLease can someone help me install this program?? I am not computer literate.
What program specifically are you struggling with? What operating system are you using? What happens when you try?
-
I need help instantly on this program please
import java.util.*;
public class D3
private static int[] z = new int[100000];
private static int first=z[0];
private static int last=z[n-1];
private static int n=100000;
public static void main(String args[])
Scanner input=new Scanner(System.in);
for(int i=0;i<z.length;i++)
z=2*i;
int seqSearch(z;50000;n); //method call 4 key where key=mid
int binSearch(z;first;last;50000);
int seqSearch(z;35467;n); //method call 4 key where key in the left half
int binSearch(z;first;last;35467);
int seqSearch(z;89703;n); //method call 4 key where key in the right half
int binSearch(z;first;last;89703);
public int seqSearch(int z[];int key;int n)
long start = System.currentTimeMillis();
int count=0;
int ans=-1;
for(int i=0;i<n;i++)
if z[i]=key
count++
{ans=i
break;}
return ans;
long elapsed = System.currentTimeMillis() - start;
System.out.print("Execution Time:" + elapsed);
System.out.print("# of Basic Operations:" + count);
public int binSearch(int z[];int first;int last;int key)
long start = System.currentTimeMillis();
int count=0;
if(last<first){
count++;
index=-1;
else
count++;
int mid=(first+last)/2
if(ket=z[mid]{
index=mid;
else
if(key<z[mid]){
index = binSearch(z[];first;mid-1;key);
else
index=binSearch(z[];mid+1;last;key);
return index;
long elapsed = System.currentTimeMillis() - start;
System.out.print("Execution Time:" + elapsed);
System.out.print("# of Basic Operations:" + count);
// if anyone could tell me whats wrong with my code i'd be greatful...the program is supposed to perform binary and sequential search on a sorted array of 100000 numbers.once on an item in the middle of the array once on the right side of it and once on the left side...i also need to count the number of basic operations for the same number in both sequential and binary to see whats better.and i need to check the time...plz i need help now,,,"Guide to a first-time poster"
you need to add exclamation marks to signify how urgent it is
e.g.
i need help instantly on this program please!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
capital letters is better
I NEED HELP INSTANTLY ON THIS PROGRAM PLEASE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
starting the italics on line 1, better again
import java.util.*;
public class D3
private static int[] z = new int[100000];
private static int first=z[0];
private static int last=z[n-1];
private static int n=100000;
public static void main(String args[])
Scanner input=new Scanner(System.in);
for(int i=0;i<z.length;i++)
z=2*i;
int seqSearch(z;50000;n); //method call 4 key where key=mid
int binSearch(z;first;last;50000);
int seqSearch(z;35467;n); //method call 4 key where key in the left half
int binSearch(z;first;last;35467);
int seqSearch(z;89703;n); //method call 4 key where key in the right half
int binSearch(z;first;last;89703);
public int seqSearch(int z[];int key;int n)
long start = System.currentTimeMillis();
int count=0;
int ans=-1;
for(int i=0;i<n;i++)
if z=key
count++
{ans=i
break;}
return ans;
long elapsed = System.currentTimeMillis() - start;
System.out.print("Execution Time:" + elapsed);
System.out.print("# of Basic Operations:" + count);
public int binSearch(int z[];int first;int last;int key)
long start = System.currentTimeMillis();
int count=0;
if(last><first){
count++;
index=-1;
else
count++;
int mid=(first+last)/2
if(ket=z[mid]{
index=mid;
else
if(key><z[mid]){
index = binSearch(z[];first;mid-1;key);
else
index=binSearch(z[];mid+1;last;key);
return index;
long elapsed = System.currentTimeMillis() - start;
System.out.print("Execution Time:" + elapsed);
System.out.print("# of Basic Operations:" + count);
and what about the dukes, offer 10 (never to be awarded, of course)
do this, then sit back and watch the replies roll in. -
i have a problem with xcode programming app when i lunch to it it asking me to enter my password and when i enter it the program show that it is wrong but am 100% sure it's wright so please help me with this issue thanks
That's not very intuitive
Check your mail server setup (mail>preferences>accounts>) choose your MobileMe account and select Outgoing Mail Server (SMTP) dropdown box, select Edit SMTP server list, verify that each instance of the me server has a password, if there are more than one and you only have one account then delete the one without a password. -
SoundFonts - small problem. Please help me because this is very important to
Hello everyone. I have just upgraded from a SoundBlaster Audigy, to a SoundBlaster X-Fi Music edition.
I have a collection of soundfonts which I used to use on my Audigy. They worked fine. Now that I'm using the X-Fi, they all work well, apart from one, and the one that doesn't work is my most used, most important soundfont.
Description of problem:
When I run my midi file, it starts playing the music using the new soundfont, but after about 0 seconds or so, the sound stops - even though the music is still playing. I then can occasionally hear a note or two, but its no longer playing properly. All my other soundfonts work perfectly, so I really dont understand why this one would cause troubles. They are all .SF2 files.
Other Information:
) I am using "SoundFont Bank Manager" to load the soundfonts. They all work great apart from the main one I want to use. It worked fine on my Audigy. The Cache part says 7.3mb Used/ 229.8mb Free.
2) I am on Windows XP Professional - Service pack 2.
3) The rest of my computer is very powerful. Its a core2duo, 2gig of RAM, 320gig seagate barracuda hard dri've etc. Regularly defragged.
4) I have the latest soundcard drivers (And direct X, video drivers, bios drivers, etc.).
5) I have no other problems with the computer.
6) My Midi program is Guitar Pro, which plays special midi files. It is set up properly, and it plays everything perfectly - using all my soundfonts, except the one I most want to use..
Please help me get this working. It is very important to me, and I need to get it working as soon as possible. I'll keep searching this thread incase I need to give any more information.
Thanks in advance.Message Edited by acrobat on 02-09-200705:0 AMWhy do you have two threads dealing with the exact same issue. That makes it confusing and hard to follow your issue to help you.
Who is your carrier, I asked in the other thread?
Have you tried YOUR sim card in another device, what happens?
1. If any post helps you please click the below the post(s) that helped you.
2. Please resolve your thread by marking the post "Solution?" which solved it for you!
3. Install free BlackBerry Protect today for backups of contacts and data.
4. Guide to Unlocking your BlackBerry & Unlock Codes
Join our BBM Channels (Beta)
BlackBerry Support Forums Channel
PIN: C0001B7B4 Display/Scan Bar Code
Knowledge Base Updates
PIN: C0005A9AA Display/Scan Bar Code -
Please help me transform this C++ code to java code....
guys...please help me transform this C++ code to java code....please try to explain the code..thanks
[program]
#include <stdio.h>
#define ALIVE 1
#define DEAD 0
#define SZ 33
int stschk (int ,int );
main()
int s[SZ][SZ], i, j;
for (i=0; i<sz; i++ ) s[0] = DEAD;
for (j=0; j<sz; j++ ) s[0][j] = DEAD;
s[0][1] = ALIVE;
for (i=0; i<sz-1; i++) {
for ( j=1;j<sz;j++ ) {
s[i][j] = stschk(s[i][j-1],s[i+1][j];
if(s[i][j-1]==ALIVE) printf("*");
else printf(" ");
printf("\n");
int stschk(int s1,int s2)
if(((s1==DEAD)&&(s2==ALIVE))||
((s1==ALIVE)&&(s2==DEAD))) return ALIVE;
else return DEAD;Being picky, that's not C++, that's C. Standard headers in C++ dont' have .h after them, loop variables are scoped with the for, you use constants rather than #defines, etc..
C and C++ both don't initialise arrays by default; you'd have to write an initialiser to get it to zero out the array:
int s[sz][sz] = {};gcc will insert a call to memset to zero the array.
If the author was assuming that the array was zeroed out, there would be no point zeroing the first row and column.
The code reads values which haven't been initialised. If you mark such values explicitly undefined, and change the program to report an error when undefined, then you get several cases where the program makes such report.
So either it' s a primitive random number generator (some random number generators use uninitialised memory as a source of randomness), or it's buggy, or it's processing undefined data and throwing away the result. Either way, it cannot be directly be ported to Java if the undefined values (which are limited to a small area of the ouput) are significant. -
Been stuck for over a year, please help me do this
so i have this laptop with 8gb ram and core i7 as well as 2 hdd (no raid).
Now i heard about premiere (cs4) and my laptop is ready to take most of the advantage but the hard drive is the bootleneck.
Basically, all i want is to do few cuts in a video that was filmed by sony hdr-sr11 camcoder in hd 1080 60i settings. Now i heard i need 3 hard drives etc, but at the moment, i only have 2.
So is there anyway i can do simple cuts in premiere without losing any quality and slowdown in fps or is there any other software that can be better? I really don't want to lose any quality or fps with the g73jh-a2 asus laptop i have?
i also have ati 5870 video cardThe lowest was 19mb, but was floating arond 30mb. Still that aint good..
I can't afford the partition magic and i heard its not good to partition after installing windows. I am thinking of fresh install, but if there is a workaround, it would save me tons of time as not installing apps etc.
For the setup
1)Can i have the programs in secondary drive? What about just a game or 2?
2)By projects, do you mean the videos that im going to edit?
3)what is scratch?
4) By media, do you mean videos im going to edit?
Lastly, what about a bit of data? Like <50gb.. Pictures documents etc
Like, truly anonymous
Date: Fri, 30 Apr 2010 17:16:10 -0600
From: [email protected]
To: [email protected]
Subject: been stuck for over a year, please help me do this
i did hdtune and was the os drive was 100mb-19mb in the end and the
secondary one was 105-45~mbps
Those figures are disturbing. For any reasonably modern 7200 RPM disk these figures should be around 120 - 60 MB/s. If it goes down to below 20, something is seriously wrong. Now that may be caused by your partitioning or something else, hard to discern from here, but these results are worrisome.
Maybe Partition Magic can help you get rid of all these partitions, otherwise a complete reformat and fresh install of OS & programs is all that is left.
Setup should be something like this:
C: OS & programs & projects
D: Pagefile, scratch and media
It depends a bit on the nature of your projects, your workflow, but in general you set up your disks in such a way that disk accesses are spread over the available disks as much as possible.
> -
PLEASE HELP ME REGARDING THIS PROBLEM
Hi friends,
I got a step by step guide for BSP and followed the steps and successfully created the Program .But while Testing the BSP Application its showing normal
" page cannot be displayed" error is coming .I checked whether server is working or not by ping on Server in command prompt . Its showing connection between my work machine and server succesfully.
What may be the error.How to check our server port on which our program reside.
Please help me in this regard.Hi Deepu,
I am getting error while double clicking on
BSP--> (ur namespace folder)
and suddenly sap is terminated.
Detailed stack dump:
7C59BC81: KERNEL32.dll! RaiseException + 86 bytes () // ?
=>5B9CE4DC: sapfront.dll! ExitSapInstallCheck + 21948 bytes () // symbols not found
7C34D5D2: MSVCR71.dll! __security_error_handler + 45 bytes () // symbols not found
60DF113F: wdttree.ocx! DllUnregisterServer + 106810 bytes () // symbols not found
60DD2D0E: wdttree.ocx! <no symbol> () // symbols not found
60DC0D00: wdttree.ocx! <no symbol> () // symbols not found
Maybe you are looking for
-
Hi there, I've a problem with my ThinkPad T410. Since one of the last pacman updates KDE shows permanently 0% battery status and the values does not increase any more. If I boot into Windows 7, however, the battery status is at 99%, So I assume that
-
When I select my ADOBE PDF printer from my printer list and print to file I don't get a PDF file. I get a PRN file. When I try to open it with ADOBE I get a "syntax error". But there's no information about what the error is. Is there anyway to get PD
-
Where can I get technical documentation about generating PDF with PDF Generator and Reader Extension
Hi, I need generate a PDF (from DOC) using PDF Generator and also Reader Extensions to enable extra functions. I've been looking for technical documentation to know how can I design this but without luck! Can somebody helps me? Thanks!!! Laura.
-
need help in validaiton for select-options.
-
Updated to 10.3.9- Issues with Acrobate Pro & Quark
Updated to OS 10.3.9, Updated Acrobate 6 to Acrobate Pro 6.0.6 (several steps) now Acrobate will not make PDFs & Quark will not Export as PDF. Any help greatly appreciated.