Help on program
SQL> create or replace package bulk_transfer is
2 type product is table of emp % rowtype index by binary_integer;
3 procedure bulk_proc(p_product in out product, p_product2 varchar2);
4 end;
5 /
Package created.
SQL> create or replace package body bulk_transfer is
2 procedure bulk_proc(p_product in out product, p_product2 varchar2)
3 is
4 cursor c_product is select * from emp;
5 begin
6 open c_product;
7 fetch c_product bulk collect into p_product;
8 close c_product;
9 forall i in 1..p_product.count
10 insert into p_product2 values p_product(i);
11 end;
12 end;
13 /
Warning: Package Body created with compilation errors.
SQL> show err
Errors for PACKAGE BODY BULK_TRANSFER:
LINE/COL ERROR
10/6 PL/SQL: SQL Statement ignored
Can I pass table name's as parameters plz give me an example if it can.
I think you should use dynamic SQL when you pass the table name as a parameter
something like:
instead of:
insert into p_product2 values p_product(i);
use
procedure bulk_proc(p_product in out product, p_product2 varchar2)
is
sql_stmt varchar2(200);
begin
sql_stmt := 'INSERT INTO ' || p_product2|| ' VALUES (:1)';
EXECUTE IMMEDIATE sql_stmt USING p_product(i) ;
end;
example:
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/13_elems18.htm#33889
Mike
Similar Messages
-
No matter what I try I can never get the Acrobat Reader to be added to the group of "Choose Helper Application" programs available in that window when downloading a pdf. I always have to browse to the Acrobat reader and select it that way.
I have enabled Acrobat in the add-ons manager, but that has not solved the problem.
In the options > applications menu I've selected use Acrobat Reader for pdf files but that doesn't work and furthermore doesn't seem to stick. That is, sometimes when I check that menu later the selection has reverted to "always ask".
I'm using Firefox 32 on Windows 7. I have used Firefox on XP for years and never had this problem.Here are some screen shots to backup my claims.
-
Hai,
Can any one give example for search help with Programming?
I hope we can create search help with help of coding.
With Regards,Jaheer.yes u can create search help by using match code in programs
for eq
go with abap editor se 38
provide the name of program
parameters : vendor like lfa1-lifnr matchcode object yzob.
double click on yzob
provide description for search help
provide selection method
provide search help parameter
enable check box for import and export
provide lpos
spos
save check activate
press f4 for check and import values i.e it will display a records list available in database table
rewards points please -
I switched to Apple Mail in the last two months. When I attempt to print an email message, I get a blank piece of paper. When I attempt to use the print options suggested in "Mail Help", the program crashes and has to be reopened. Any ideas?
Which version of Mail are you using as well as which Snow Leopard version you are using?
-
Adding the search help in program
hi i want to add a search help in program for a particular field of a parameter how to do this?
U need to create a serach help exit for this purpose.
F4IF_SHLP_EXIT_EXAMPLE - documents the different reasons to use a search help exit, and shows how it is done.
http://www.sapdevelopment.co.uk/dictionary/shelp/shelp_exit.htm
http://www.sapdevelopment.co.uk/dictionary/shelp/shelp_basic.htm
Create an Elementary Search help:
Eg: Zsearch
In the defintion tab:
Give the search help exit name: Zsearch_exit.
Also give the search help param and data element.
Copy F4IF_SHLP_EXIT_EXAMPLE into Zsearch_exit
Comment:
callcontrol-step = 'SELECT'. (1st line)
Inside:
IF CALLCONTROL-STEP = 'SELECT'.
Select required data for the search help
Select stmnts as per your requirement and populate in itab.
Move all the selected records to Record_Tab
LOOP AT itab INTO wa_itab.
MOVE wa_itab TO record_tab-string.
APPEND record_tab.
CLEAR record_tab.
ENDLOOP.
RC = 0 .
IF RC = 0.
CALLCONTROL-STEP = 'DISP'.
ELSE.
CALLCONTROL-STEP = 'EXIT'.
ENDIF.
EXIT. "Don't process STEP DISP additionally in this call.
Let me know if its working for you.
Also, chek this link if it helps you:Re: Find Storage location with respect to Plant -
I want parameters with f4 help for program names in value request
I want parameters with f4 help for program names in value request
points will be awarded if usefullv_name1 TYPE name1, "Vendor Name
CALL FUNCTION 'POPUP_TO_SEARCH_VALUE'
EXPORTING
textline1 = 'Vendor Name'(f09)
titel = 'Enter'(f17)
valuelength = 35
IMPORTING
value = lv_name1.
try this out .. -
Hi all,
is anyone able to explain me how to use Search Help freely programmed?
thanks
GNHi Gabriele,
Please go through the component DEMO_VALUE_HELP. This explains all the input help types. The freely programmed search help has been implemented for the CONNID input field of view V1. The Web Dynpro component FREE_VALUE_HELP in the same package is the component where the search help is coded.
Also below are the steps to be followed for implementing the freely programmed search help.
This kind of value help is implemented as a Web Dynpro component implementing the Web Dynpro
component interface IWD_VALUE_HELP. To be able to use the value help for a certain input field, the following steps are necessary:
1) A component usage of the value help component (HC) has to be declared
by the consumer component (CC).
2) A usage of the HC interface controller has to be declared in the CC view.
3) The input help mode User-Defined Programming has to be chosen for the attribute that is bound to the input field under consideration. The HC usage must be related to this attribute. The component interface of the HC has only one method: set_value_help_listener( ). This method is called by the Web Dynpro runtime if the value help button of the input field under consideration is clicked. The HC has to be implemented as follows:
1) The method set_value_help_listener( ) has an import parameter. This means that the reference to the listener, provided by the Web Dynpro runtime, is passed to the user-defined HC. This reference has to be saved as a user defined controller attribute.
2) To close the help value dialog box, the close_window( ) method of the listener has to be used.
3) All views have to be embedded into a window having the name WD_VALUE_HELP. This name is used by the Web Dynpro runtime.
4) To exchange data between the CC and the HC, context mapping can be used.
For implementing the component interface IWD_VALUE_HELP, you need to choose the Reimplement button in the HC. The implementation status changes to green and the events and the method of the component interface are visible in the HC controller.
Regards,
Uday -
HELP - ABAP Program Cancelled After Running for 2.5 Hours in Background
I have an ABAP report program that was being tested in our QA system and it died after running for 2.5 hours with the status of "Cancelled" (which, I assume, means it was terminated by SAP for exceeding some type of governor).
I ran Code Analyzer and no performance issues were recognized.
I am running several SELECT statements during program execution. These are a list of all the SELECT statements used in my program. Also, I'm using PNPCE to get a list of pernrs for which to pull data at the beginning of the program.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE gt_p0167
FROM pa0167
WHERE pernr EQ gt_selected_pernrs
AND bplan IN s_bplan
AND begda LE pn-endda
AND endda GE pn-begda.
SELECT SINGLE fgbdt fasex
INTO (lv_dob, lv_gender)
FROM pa0021
WHERE pernr EQ gt_selected_pernrs
AND subty EQ <fs_dtyxx>
AND objps EQ <fs_didxx>
AND begda LE pn-endda
AND endda GE pn-begda.
SELECT SINGLE agency ansvh
INTO (p_agency_out, lv_ansvh)
FROM pa0001
WHERE pernr EQ p_pernr_in
AND begda LE pn-endda
AND endda GE pn-begda.
SELECT SINGLE vorna nachn gbdat perid gesch
INTO (gt_control_table-fname, gt_control_table-lname, gt_control_table-dob, gt_control_table-mskssn, gt_control_table-gender)
FROM pa0002
WHERE pernr EQ p_pernr_in
AND begda LE pn-endda
AND endda GE pn-begda.
SELECT SINGLE perid
INTO (lv_ssn)
FROM pa0106
WHERE pernr EQ p_pernr_in
AND subty EQ p_subty_in
AND objps EQ p_objps_in
AND begda LE pn-endda
AND endda GE pn-begda.
SELECT SINGLE smoke
INTO (p_smoker_out)
FROM pa0376
WHERE pernr = p_pernr_in
AND begda LE pn-endda
AND endda GE pn-begda.
SELECT SINGLE state pstlz zcounty
INTO (p_state_out, lv_zip, p_county_out)
FROM pa0006
WHERE pernr EQ p_pernr_in
AND begda LE pn-endda
AND endda GE pn-begda.
SELECT SINGLE werks btrtl
INTO (lv_werks, lv_btrtl)
FROM pa0001
WHERE pernr EQ p_pernr_in
AND begda LE pn-endda
AND endda GE pn-begda.
SELECT SINGLE region
INTO (p_region_out)
FROM zpat_county_code
WHERE county EQ p_county_in.
SELECT SINGLE pernr
INTO lv_pernr
FROM pa0002
WHERE perid EQ gt_cobra_table-l_essn.
SELECT SINGLE eecst ercst
INTO (lv_eecst, lv_ercst)
FROM t5ubi
WHERE barea EQ '01'
AND bplan EQ lv_bplan
AND bcost EQ p_bcost_in
AND cstv1 EQ '0001'
AND smoke EQ p_smoker_in
AND begda LE pn-endda
AND endda GE pn-begda.
SELECT SINGLE kwert
INTO lv_kwert
FROM t511k
WHERE molga EQ '10'
AND konst EQ 'ZCOB1'
AND begda LE pn-endda
AND endda GE pn-begda.The screen shot the tester sent me only says that it was canceled. However, the log shows the following:
09/17/2008 16:54:32 Job Started
09/17/2008 16:54:32 Step 001 started (program ZBNI001...
09/17/2008 19:22:09 ABAP/4 processor: DATASET_NOT_OPEN
09/17/2008 19:22:09 Job cancelled
I'm not sure it was an error, per se, but maybe SAP canceled it because it had been running too long? The "DATASET_NOT_OPEN" is curious although I've no idea what it means.
Thanks for your help. -
Please help, java program terminating unexpectedly without reason
ok, so I have a project I'm working on, here's its description:
Create a new project named FML_Pig where F is your first initial, M is your middle initial, and L is your last initial. For example, if your name is Alfred Edward Neuman then you would name your project AEN_Pig. If necessary, add a new Java file to this project named FML_Pig.
Add a java file to the project named FML_Dice.
Design and implement a Dice class as follows. The Dice class has 2 twenty‑sided dice with numbers on the faces (1 � 20) and 2 twenty-six-sided dice with letters on the faces (a � z).
import java.util.Random;
public class FML_Dice
private static Random gen = new Random();
private final static int NUM_SIDES = 20;
private int die1, die2, numSnakeEyes, numVowels, totalPoints;
private char die3, die4;
Part 1
Add a rollDice() method to your FML_Dice class that sets die1 and die2 to a random number between 1 and 20 and it sets die3 and die4 to a random character between �a� and �z�.
Helpful Hint:
dice3 = (char)(�a� + gen.nextInt(26)); // sets dice3 to a random char between �a� and �z�.
Part 2
Write a constructor that sets die1 and die2 to a random number between 1 and 20 and it sets die3 and die4 to a random character. Your constructor can simply call rollDice() to do this. It should also initialize numSnakeEyes, numVowels, and totalPoints to 0 (after you roll the dice).
Part 3
Write methods getDie1(), getDie2(), getDie3(), and getDie4() that returns the value of the respective die. Write a method numSnakes() that returns the number of snake eyes that have been rolled. Write a method numVowels() that returns the number of vowels that have been rolled. Write a method totalPts() that returns the totalPoints.
Part 4
Write a toString() method that overwrites the default toString() method. It should return a String representation of the value of all 4 die. For example, 17 2 h w.
Part 5
Write a method updateTotals that updates numVowels, numSnakeEyes, and totalPoints based on the current values of die1, die2, die3, and die4. numVowels should be incremented by 1 if either die3 or die4 are a vowel. However, if both die3 and die4 are vowels, the totalPoints should be reset to 0 and numVowels should be reset to 0 also. numSnakeEyes should be incremented by 1 if either die1 or die2 have a face value of 1 (this is not truly a snake eyes, but it gives better odds for the game). totalPoints should be incremented by the sum of die1 and die2 multiplied by (numSnakeEyes + 1).
Part 6
Write a main program (use the one in FML_Pig.java) that plays a game of Pig. In this game, two people play against each other. Player1 begins by rolling the dice. The total of die1 and die2 is added to his total score. Player1�s turn continues until he/she rolls a total of 4 vowels then the turn switches to Player2. Whenever a turn switches to the other player, the number of vowels is reset to zero. Also, if at any time both die3 and die4 are vowels, the total score is reset to 0 and the turn switches to the other player. (So the turn switches to the other player whenever the total number of vowels reaches four or there are two vowels rolled at the same time.)
If a player rolls snakeeyes (for our game, snakeeyes occurs whenever either of the dice have a face value of one � in reality, both die1 and die2 should have a face value of one but then snakeeyes would occur only once every 400 rolls), then his point values are doubled from that point on (all future rolls for the rest of the game, point values for this player are doubled). When a player rolls snake eyes again, point values are tripled for that roll and all future rolls. (Three snake eyes, quadrupled, etc.)
(continued on the next page)
Be sure to display the results of the roll for each turn.
First player to get to 2000 points wins the game and gets to oink like a pig.
Note: Both players need their own set of Dice since the Dice keeps track of the totalPoints, the number of snake eyes rolled so far, and the number of vowels rolled so far for that particular player. You can do this simply by declaring it that way in the main program:
Dice player1 = new Dice();
Dice player2 = new Dice();
You may add additional methods and instance variables to the class as needed. For example, I would probably write a private helper method isVowel() that is passed a char argument ch and returns true if ch is a vowel.
Also, you can have the computer play for both player 1 and player 2. Simply loop it until somebody wins. Print out the result for each turn including who rolled the dice (player 1 or player 2), what they rolled, how many snakeeyes do they have, how many points did they get for this turn, and how many total points do they have.
When you are completely finished, hand in just the java files (FLM_Dice & FLM_Pig). If you happened to write any other classes, make sure they are named with the FML format, and turn these in as well. I do not need EasyReader or p.
Oink! Oink!
This pig won the game --------->
so here's my code:
this isn't my code but is required to compile my code: // package com.skylit.io;
import java.io.*;
* @author Gary Litvin
* @version 1.2, 5/30/02
* Written as part of
* <i>Java Methods: An Introduction to Object-Oriented Programming</i>
* (Skylight Publishing 2001, ISBN 0-9654853-7-4)
* and
* <i>Java Methods AB: Data Structures</i>
* (Skylight Publishing 2003, ISBN 0-9654853-1-5)
* EasyReader provides simple methods for reading the console and
* for opening and reading text files. All exceptions are handled
* inside the class and are hidden from the user.
* <xmp>
* Example:
* =======
* EasyReader console = new EasyReader();
* System.out.print("Enter input file name: ");
* String fileName = console.readLine();
* EasyReader inFile = new EasyReader(fileName);
* if (inFile.bad())
* System.err.println("Can't open " + fileName);
* System.exit(1);
* String firstLine = inFile.readLine();
* if (!inFile.eof()) // or: if (firstLine != null)
* System.out.println("The first line is : " + firstLine);
* System.out.print("Enter the maximum number of integers to read: ");
* int maxCount = console.readInt();
* int k, count = 0;
* while (count < maxCount && !inFile.eof())
* k = inFile.readInt();
* if (!inFile.eof())
* // process or store this number
* count++;
* inFile.close(); // optional
* System.out.println(count + " numbers read");
* </xmp>
public class EasyReader
protected String myFileName;
protected BufferedReader myInFile;
protected int myErrorFlags = 0;
protected static final int OPENERROR = 0x0001;
protected static final int CLOSEERROR = 0x0002;
protected static final int READERROR = 0x0004;
protected static final int EOF = 0x0100;
* Constructor. Prepares console (System.in) for reading
public EasyReader()
myFileName = null;
myErrorFlags = 0;
myInFile = new BufferedReader(
new InputStreamReader(System.in), 128);
* Constructor. opens a file for reading
* @param fileName the name or pathname of the file
public EasyReader(String fileName)
myFileName = fileName;
myErrorFlags = 0;
try
myInFile = new BufferedReader(new FileReader(fileName), 1024);
catch (FileNotFoundException e)
myErrorFlags |= OPENERROR;
myFileName = null;
* Closes the file
public void close()
if (myFileName == null)
return;
try
myInFile.close();
catch (IOException e)
System.err.println("Error closing " + myFileName + "\n");
myErrorFlags |= CLOSEERROR;
* Checks the status of the file
* @return true if en error occurred opening or reading the file,
* false otherwise
public boolean bad()
return myErrorFlags != 0;
* Checks the EOF status of the file
* @return true if EOF was encountered in the previous read
* operation, false otherwise
public boolean eof()
return (myErrorFlags & EOF) != 0;
private boolean ready() throws IOException
return myFileName == null || myInFile.ready();
* Reads the next character from a file (any character including
* a space or a newline character).
* @return character read or <code>null</code> character
* (Unicode 0) if trying to read beyond the EOF
public char readChar()
char ch = '\u0000';
try
if (ready())
ch = (char)myInFile.read();
catch (IOException e)
if (myFileName != null)
System.err.println("Error reading " + myFileName + "\n");
myErrorFlags |= READERROR;
if (ch == '\u0000')
myErrorFlags |= EOF;
return ch;
* Reads from the current position in the file up to and including
* the next newline character. The newline character is thrown away
* @return the read string (excluding the newline character) or
* null if trying to read beyond the EOF
public String readLine()
String s = null;
try
s = myInFile.readLine();
catch (IOException e)
if (myFileName != null)
System.err.println("Error reading " + myFileName + "\n");
myErrorFlags |= READERROR;
if (s == null)
myErrorFlags |= EOF;
return s;
* Skips whitespace and reads the next word (a string of consecutive
* non-whitespace characters (up to but excluding the next space,
* newline, etc.)
* @return the read string or null if trying to read beyond the EOF
public String readWord()
StringBuffer buffer = new StringBuffer(128);
char ch = ' ';
int count = 0;
String s = null;
try
while (ready() && Character.isWhitespace(ch))
ch = (char)myInFile.read();
while (ready() && !Character.isWhitespace(ch))
count++;
buffer.append(ch);
myInFile.mark(1);
ch = (char)myInFile.read();
if (count > 0)
myInFile.reset();
s = buffer.toString();
else
myErrorFlags |= EOF;
catch (IOException e)
if (myFileName != null)
System.err.println("Error reading " + myFileName + "\n");
myErrorFlags |= READERROR;
return s;
* Reads the next integer (without validating its format)
* @return the integer read or 0 if trying to read beyond the EOF
public int readInt()
String s = readWord();
if (s != null)
return Integer.parseInt(s);
else
return 0;
* Reads the next double (without validating its format)
* @return the number read or 0 if trying to read beyond the EOF
public double readDouble()
String s = readWord();
if (s != null)
return Double.parseDouble(s);
// in Java 1, use: return Double.valueOf(s).doubleValue();
else
return 0.0;
}same with this:
public class p
public static void l(String S)
{ System.out.println(S);}
public static void o(String S)
{System.out.print(S);}
public static void l(int i)
{ System.out.println(i);}
public static void o(int i)
{System.out.print(i);}
public static void l(boolean b)
{ System.out.println(b);}
public static void o(boolean b)
{System.out.print(b);}
public static void l(char c)
{ System.out.println(c);}
public static void o(char c)
{System.out.print(c);}
public static void l(double d)
{ System.out.println(d);}
public static void o(double d)
{System.out.print(d);}
public static void l(Object obj)
{ System.out.println(obj.toString());}
public static void o(Object obj)
{System.out.print(obj.toString());}
public static void l()
{System.out.println();}
} here's my code:
import java.util.*;
public class JMM_Pig
public static void main(String[] args)
int winner=0;
int pts=0;
JMM_Dice player1=new JMM_Dice();
JMM_Dice player2=new JMM_Dice();
p.l("Player 1 rolls the dice...");
player1.rollDice();
player1.updateTotals();
boolean loop=true;
while(loop)
while(player1.numVowels()<=4)
p.l("Player 1 continues his turn...");
player1.rollDice();
player1.updateTotals();
p.l("Player 1 rolled a "+player1.getDie1()+" and a "+player1.getDie2()+" and a '"+player1.getDie3()+"' and a '"+player1.getDie4()+"'");
p.l("Player 1 rolled "+player1.currvowels()+" vowels.");
p.l("Player 1 has "+player1.totalvowels()+" total vowels.");
//if(player1.getMagic()==1)
//player1.totalPoints=(player1.totalPoints+player1.getDie1()+player1.getDie2())*player1.mult;
//pts=(player1.totalPts()+player1.getDie1()+player1.getDie2())*player1.getMult();
//player1.setTpts(pts);
//if(player1.getMagic()!=1)
//player1.totalPoints=player1.totalPoints+player1.getDie1()+player1.getDie2();
//pts=player1.totalPts()+player1.getDie1()+player1.getDie2();
//player1.setTpts(pts);
p.l("Player 1 has "+player1.numSnakes()+" snake eyes.");
p.l("Player 1 earned "+player1.ptsreturn()+" points this turn.");
p.l("Player 1 has "+player1.totalPts()+" total points.");
pts=0;
if(player1.totalPts()>=2000)
winner=1;
player1.setNv(4);loop=false;
if((player1.isavowel(player1.getadice()))&&player1.isavowel(player1.getadice2()))
player1.setTpts(0);player1.setNv(0);player1.setNv(4);
p.l("Player 1's turn has ended...");
player1.setNv(0);
p.l("Player 2 rolls the dice...");
player2.rollDice();
player2.setTpts(player2.totalPts()+player2.getDie1()+player2.getDie2());
while(player2.numVowels()<=4)
p.l("Player 2 continues his turn...");
player2.rollDice();
player2.updateTotals();
p.l("Player 2 rolled a "+player2.getDie1()+" and a "+player2.getDie2()+" and a '"+player2.getDie3()+"' and a '"+player2.getDie4()+"'");
p.l("Player 2 rolled "+player2.currvowels()+" vowels.");
p.l("Player 2 has "+player2.totalvowels()+" total vowels.");
//if(player1.getMagic()==1)
//player1.totalPoints=(player1.totalPoints+player1.getDie1()+player1.getDie2())*player1.mult;
//pts=(player1.totalPts()+player1.getDie1()+player1.getDie2())*player1.getMult();
//player1.setTpts(pts);
//if(player1.getMagic()!=1)
//player1.totalPoints=player1.totalPoints+player1.getDie1()+player1.getDie2();
//pts=player1.totalPts()+player1.getDie1()+player1.getDie2();
//player1.setTpts(pts);
p.l("Player 2 has "+player2.numSnakes()+" snake eyes.");
p.l("Player 2 earned "+player2.ptsreturn()+" points this turn.");
p.l("Player 2 has "+player2.totalPts()+" total points.");
pts=0;
if(player2.totalPts()>=2000)
winner=2;
player2.setNv(4);loop=false;
if((player2.isavowel(player2.getadice()))&&player2.isavowel(player2.getadice2()))
player2.setTpts(0);player2.setNv(0);player2.setNv(4);
p.l("Player 2's turn has ended...");
player2.setNv(0);
if(player1.totalPts()>=2000)
winner=1;
loop=false;
if(player2.totalPts()>=2000)
winner=2;
loop=false;
} //main loop
if(winner==1)
p.l("It ended with the following statistics...");
p.l("Player 1's score was: "+player1.totalPts()+" and Player 2's score was: "+player2.totalPts());
p.l("Player 1 had: "+player1.numSnakes()+" snake eye(s) and Player 2 had: "+player2.numSnakes()+" snake eye(s)");
p.l("Player 1 wins, oink oink!");
if(winner==2)
p.l("It ended with the following statistics...");
p.l("Player 1's score was: "+player1.totalPts()+" and Player 2's score was: "+player2.totalPts());
p.l("Player 1 had: "+player1.numSnakes()+" snake eye(s) and Player 2 had: "+player2.numSnakes()+" snake eye(s)");
p.l("Player 2 wins, oink oink!");
and dice class:
import java.util.*;
public class JMM_Dice {
private static Random gen = new Random();
private final static int NUM_SIDES = 21;
private int die1, die2, numSnakeEyes, numVowels, totalPoints;
private char die3, die4;
private int dice=0;
//dice=
private int dice2=0;
//dice2=;
private String adice="";
//adice=;
private String adice2="";
//adice2;
private int magic=0;
private int mult=0;
private int currvowels=0;
private int totalvowels=0;
public static EasyReader key = new EasyReader();
public JMM_Dice()
dice=0;dice2=0;
String alpha="abcdefghijklmnopqrstuvwxyz";
adice="";adice2="";
rollDice();
numSnakeEyes=0;numVowels=0;totalPoints=0;
public void setTpts(int tpts)
this.totalPoints=tpts;
public void setNv(int nv)
this.numVowels=nv;
public int getDie1()
return dice;
public int getDie2()
return dice2;
public String getDie3()
return adice;
public String getDie4()
return adice2;
public int numSnakes()
return numSnakeEyes;
public void setSnakes(int s)
this.numSnakeEyes=s;
public String getadice()
return this.adice;
public String getadice2()
return this.adice2;
public int numVowels()
return numVowels;
public int getMagic()
return this.magic;
public int getNv()
return this.numVowels;
public void setMagic(int mag)
this.magic=mag;
public int getMult()
return this.mult;
public void setMult(int m)
this.mult=m;
public int totalPts()
return totalPoints;
public String toString()
return dice+""+dice2+""+adice+""+adice2;
public boolean isavowel(String str)
if(str.equals("a")||str.equals("e")||str.equals("i")||str.equals("o")||str.equals("u"))
return true;
else
return false;
public int ptsreturn()
return dice+dice2;
public int currvowels()
int tmp=currvowels;
currvowels=0;
return tmp;
public int totalvowels()
return numVowels;
public void updateTotals()
if(adice.equalsIgnoreCase("a")||adice.equalsIgnoreCase("e")||adice.equalsIgnoreCase("i")||adice.equalsIgnoreCase("o")||adice.equalsIgnoreCase("u")||adice2.equalsIgnoreCase("a")||adice2.equalsIgnoreCase("e")||adice2.equalsIgnoreCase("i")||adice2.equalsIgnoreCase("o")||adice2.equalsIgnoreCase("u"))
numVowels++;currvowels++;
if((isavowel(adice))&&isavowel(adice2))
totalPoints=0;numVowels=0;
if(dice==1||dice2==1)
numSnakeEyes++;
int fd=dice;
int sd=dice2;
int sum=fd+sd;
totalPoints+=sum*(numSnakeEyes+1);
public void rollDice()
dice=gen.nextInt(20)+1;
dice2=gen.nextInt(20)+1;
String alpha="abcdefghijklmnopqrstuvwxyz";
adice=String.valueOf(alpha.charAt(gen.nextInt(26)));
adice2=String.valueOf(alpha.charAt(gen.nextInt(26)));
public static void sleep (int wait)
{ long timeToQuit = System.currentTimeMillis() + wait;
while (System.currentTimeMillis() < timeToQuit)
; // take no action
}the program works fine except it's supposed to terminate when one of the two AIs get a score of 2000, right now it terminates no matter what score the AIs get and no matter what I've tried to do it keeps doing that...can someone please tell me why it's terminating so oddly? Thanks! :)Here's how my code works in a nutshell, the main program starts with the boolean loop=true;
while(loop)
{then comes the loops for the two AIs, first the player 1 AI goes with this loop: while(player1.numVowels()<=4)
{there the player 1 roles the dice and it keeps going until player 1 gets a total of 2000 points at which time this is supposed to execute: if(player1.totalPts()>=2000)
winner=1;
player1.setNv(4);loop=false;
}, player1.setNv(4); sets numVowels to 4 so that the inner loop exits, loop=false exits the other loop and winner=1; specifies that player 1 won which is used outside of the loops here: if(winner==1)
p.l("It ended with the following statistics...");
p.l("Player 1's score was: "+player1.totalPts()+" and Player 2's score was: "+player2.totalPts());
p.l("Player 1 had: "+player1.numSnakes()+" snake eye(s) and Player 2 had: "+player2.numSnakes()+" snake eye(s)");
p.l("Player 1 wins, oink oink!");
if(winner==2)
p.l("It ended with the following statistics...");
p.l("Player 1's score was: "+player1.totalPts()+" and Player 2's score was: "+player2.totalPts());
p.l("Player 1 had: "+player1.numSnakes()+" snake eye(s) and Player 2 had: "+player2.numSnakes()+" snake eye(s)");
p.l("Player 2 wins, oink oink!");
} the same thing happens for player 2 if player 1 didn't already get 2000 points...but the if statement despite everything pointing to the variables containing the right values don't seem to be working, as shown by the example program output I posted it just ends at any random number...hopefully this helps make figuring out what's wrong easier :) ...so can anyone please help me out? thanks! :) -
Urgent please help, this program should work
Urgent please help.
I need to solve or I will be in big trouble.
This program works at my home computer which is not networked.
The hard disk was put onto another computer at another location whihc is networked. Here my program worked on Monday 14 october but since for the last two days it is not working without me changing any code. Why do I receive this error message???
Error: 500
Location: /myJSPs/jsp/portal-project2/processviewfiles_dir.jsp
Internal Servlet Error:
javax.servlet.ServletException
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at jsp.portal_0002dproject2.processviewfiles_dir_1._jspService(processviewfiles_dir_1.java:162)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
Root cause:
java.lang.NullPointerException
at jsp.portal_0002dproject2.processviewfiles_dir_1._jspService(processviewfiles_dir_1.java:132)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)foolishmatt,
The code is quit large.
to understand the program I think all the code needs to be examined.
I would need to send to you in an email.
Here is my e-mail
[email protected]
if you contact me than I can send the code to you.
Thank you in advance. -
Need help with program for Inner join
Hello Experts,
I need to create a list from table sbook containing booking number (sbook-bookid), customer number (sbook-customid), customer name (scustom-name) , customer class (sbook-class) and ticket price (sflight-price). I am new to ABAP and am very confused I tried reading up some examples and came up with the attached program
Attached is my program for inner join
Kindly Help
Thanks SuHi Su K
You May use key fields , Foreign keys for joining , Here
SELECT SBOOK~BOOKID SBOOK~CUSTOMID SBOOK~CLASS
SCUSTOM~ID SCUSTOM~NAME FROM SFILGHT
INNER JOIN SBOOK ON SBOOK~CARRID EQ SFILGHT~CARRID
SBOOK~CONNID EQ SFILGHT~CONNID
SBOOK~FLDATE EQ SFILGHT~FLDATE
INNER JOIN SCUSTOM ON SCUSTOM~ID = SBOOK~ID -
Hi everybody,
I designed a calculator, and I need help with the rest of the scientific actions. I know I need to use the different Math methods, but what exactly? Also, it needs to work as an applet and application, and in the applet, the buttons don't appear in order, how can I fix that?
I will really appreciate your help with this program, I need to finish it ASAP. Please e-mail me at [email protected].
Below is the code for the calcualtor.
Thanks in advance,
-Maria
// calculator
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
public class calculator extends JApplet implements
ActionListener
private JButton one, two, three, four, five, six, seven,
eight, nine, zero, dec, eq, plus, minus, mult, div, clear,
mem, mrc, sin, cos, tan, asin, acos, atan, x2, sqrt, exp, pi, percent;
private JLabel output, blank;
private Container container;
private String operation;
private double number1, number2, result;
private boolean clear = false;
//GUI
public void init()
container = getContentPane();
//Title
//super("Calculator");
JPanel container = new JPanel();
container.setLayout( new FlowLayout( FlowLayout.CENTER
output = new JLabel("");
output.setBorder(new MatteBorder(2,2,2,2,Color.gray));
output.setPreferredSize(new Dimension(1,26));
getContentPane().setBackground(Color.white);
getContentPane().add( "North",output );
getContentPane().add( "Center",container );
//blank
blank = new JLabel( " " );
container.add( blank );
//clear
clear = new JButton( "CE" );
clear.addActionListener(this);
container.add( clear );
//seven
seven = new JButton( "7" );
seven.addActionListener(this);
container.add( seven );
//eight
eight = new JButton( "8" );
eight.addActionListener(this);
container.add( eight );
//nine
nine = new JButton( "9" );
nine.addActionListener(this);
container.add( nine );
//div
div = new JButton( "/" );
div.addActionListener(this);
container.add( div );
//four
four = new JButton( "4" );
four.addActionListener(this);
container.add( four );
//five
five = new JButton( "5" );
five.addActionListener(this);
container.add( five );
//six
six = new JButton( "6" );
six.addActionListener(this);
container.add( six );
//mult
mult = new JButton( "*" );
mult.addActionListener(this);
container.add( mult );
//one
one = new JButton( "1" );
one.addActionListener(this);
container.add( one );
//two
two = new JButton( "2" );
two.addActionListener(this);
container.add( two );
//three
three = new JButton( "3" );
three.addActionListener(this);
container.add( three );
//minus
minus = new JButton( "-" );
minus.addActionListener(this);
container.add( minus );
//zero
zero = new JButton( "0" );
zero.addActionListener(this);
container.add( zero );
//dec
dec = new JButton( "." );
dec.addActionListener(this);
container.add( dec );
//plus
plus = new JButton( "+" );
plus.addActionListener(this);
container.add( plus );
//mem
mem = new JButton( "MEM" );
mem.addActionListener(this);
container.add( mem );
//mrc
mrc = new JButton( "MRC" );
mrc.addActionListener(this);
container.add( mrc );
//sin
sin = new JButton( "SIN" );
sin.addActionListener(this);
container.add( sin );
//cos
cos = new JButton( "COS" );
cos.addActionListener(this);
container.add( cos );
//tan
tan = new JButton( "TAN" );
tan.addActionListener(this);
container.add( tan );
//asin
asin = new JButton( "ASIN" );
asin.addActionListener(this);
container.add( asin );
//acos
acos = new JButton( "ACOS" );
cos.addActionListener(this);
container.add( cos );
//atan
atan = new JButton( "ATAN" );
atan.addActionListener(this);
container.add( atan );
//x2
x2 = new JButton( "X2" );
x2.addActionListener(this);
container.add( x2 );
//sqrt
sqrt = new JButton( "SQRT" );
sqrt.addActionListener(this);
container.add( sqrt );
//exp
exp = new JButton( "EXP" );
exp.addActionListener(this);
container.add( exp );
//pi
pi = new JButton( "PI" );
pi.addActionListener(this);
container.add( pi );
//percent
percent = new JButton( "%" );
percent.addActionListener(this);
container.add( percent );
//eq
eq = new JButton( "=" );
eq.addActionListener(this);
container.add( eq );
//Set size and visible
setSize( 190, 285 );
setVisible( true );
public static void main(String args[]){
//execute applet as application
//applet's window
JFrame applicationWindow = new JFrame("calculator");
applicationWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//applet instance
calculator appletObject = new calculator();
//init and start methods
appletObject.init();
appletObject.start();
} // end main
public void actionPerformed(ActionEvent ae)
JButton but = ( JButton )ae.getSource();
//dec action
if( but.getText() == "." )
//if dec is pressed, first check to make shure there
is not already a decimal
String temp = output.getText();
if( temp.indexOf( '.' ) == -1 )
output.setText( output.getText() + but.getText() );
//clear action
else if( but.getText() == "CE" )
output.setText( "" );
operation = "";
number1 = 0.0;
number2 = 0.0;
//plus action
else if( but.getText() == "+" )
operation = "+";
number1 = Double.parseDouble( output.getText() );
clear = true;
//output.setText( "" );
//minus action
else if( but.getText() == "-" )
operation = "-";
number1 = Double.parseDouble( output.getText() );
clear = true;
//output.setText( "" );
//mult action
else if( but.getText() == "*" )
operation = "*";
number1 = Double.parseDouble( output.getText() );
clear = true;
//output.setText( "" );
//div action
else if( but.getText() == "/" )
operation = "/";
number1 = Double.parseDouble( output.getText() );
clear = true;
//output.setText( "" );
//eq action
else if( but.getText() == "=" )
number2 = Double.parseDouble( output.getText() );
if( operation == "+" )
result = number1 + number2;
else if( operation == "-" )
result = number1 - number2;
else if( operation == "*" )
result = number1 * number2;
else if( operation == "/" )
result = number1 / number2;
//output result
output.setText( String.valueOf( result ) );
clear = true;
operation = "";
//default action
else
if( clear == true )
output.setText( "" );
clear = false;
output.setText( output.getText() + but.getText() );Multiple post:
http://forum.java.sun.com/thread.jsp?forum=31&thread=474370&tstart=0&trange=30 -
Help T_T - Program not compiling properly
I'm trying to add a short animation to the source file for a
game that was built by an outside studio. Unfortunately, I can't
seem to get the program to compile correctly: I get tons of errors,
graphics dont diplay properly, etc. I thought perhaps I had just
messed something up with my codes and animations, but even if i try
to compile the original unedited file as a control test, i get the
same problems. I have all the external files, scripts, etc.
None of our scripters are in-house, so there's no one I can
ask about this. I know just enough actionscript to prevent Flash
from exploding into a gooey mass (which is how I ended up getting
tasked with this), but basically my knowledge of flash is limited
to it as an animation program so I'm not really sure if theres some
kind of settings I need to change, specifically need to export as
an .exe (shouldn't be, since the game runs as a .swf), or what.
I know i'm not providing a whole lot of information about the
problem, but thats because I'm not really sure what info is
relevant. Let me know if there's anything people need from me and
I'll get it to you.
Thanks!Just a had brief look, but shouldn't it be:public class TempConversion extends JFrameIf you post code it is a good idea to use the formatting tags:
http://forum.java.sun.com/help.jspa?sec=formatting
Basically the idea is you put [code] at the start of your code and [/code]
at the end. -
public class Reverse{
�@public static void main(String[] args)
{ int i,j;
for(i=args.length-1;i>=0;i--)
{ for (j=args[i].length()-1;j>=0;j--) System.out.print(args.charAt(j));
System.out.print(" ");
System.out.println();
I wrote the program but there ia an error
Invalid character in input
public static void main(String[] args)
I really can not realize what is the mistake? Can anyone help me?
Thanks a lot!public class Reverse{
�@public static void main(String[] args)You think the stuff in bold should be there? What makes you think that? -
can someone tell me whats wrong with this program? It's in my programming book and i can't get it to work.
class Sundae {
private Sundae() {}
static Sundae makeASundae() {
return new Sundae();
public class IceCream {
public static void main(String[] args) {
Sundae x = new Sundae.makeASundae();
I end up getting one of these things ^ under the period in Sundae.makeASundae(). Can you help me??You are not instantiating the Class Sundae. You are attempting to call a method from a non-exsistant object and asking it to create itself. That's a no-no.
Look at the code below. It will work fine.
class Sundae {
public Sundae() {}
static void makeASundae() {
System.out.println("I made it here.");
public class IceCream {
public static void main(String[] args) {
Sundae x = new Sundae();
x.makeASundae();
} -
Hello,
I am having trouble running my program in the command prompt. I got it to compile etc.
Its a program that involves inputting a list of numbers. BUt when I press "Enter" after inputting the list, nothing happens. Is there something to signify that I have stopped inputting numbers? For example, in Linux, when you press Ctrl+D, it signifies the end of the inputting of numbers and the program runs.
Any help appreciated. Thanks.Okay, I'm using a class file, and a driver file which calls the methods.
Here is the Driver.java file
package integer;
class Driver
public static void main(String args[])
IntegerList list = new IntegerList();
list.readIn( "Please input a lost of integers : " );
list.mostCommon();
}Here is IntegerList.java
package integer;
import java.util.ArrayList;
import java.util.Scanner;
class IntegerList extends ArrayList< Integer >
// Various Methods for Manipulating a List of Integers
//===========================================================================
public void readIn( String prompt )
// Output 'prompt, then input integers from 'System.in',
// appending them, in order, onto the end of this list
Scanner input = new Scanner( System.in );
System.out.printf( "%s", prompt );
while ( input.hasNext( ) )
add( input.nextInt( ) );
//===========================================================================
public void writeOut( String title )
// Output 'title' and all the values in this list on a single line
System.out.printf( "%s", title );
for ( int item : this )
System.out.printf( "%d ", item );
System.out.printf( "%n" );
//===========================================================================
public int count( int item )
// Return the number of times that 'item' occurs in this list.
int counter=0;
for ( int num : this )
if ( item == num )
counter++;
System.out.printf( "%d ", counter );
return counter;
//===========================================================================
public int mostCommon( )
int max=0;
int result=0;
for ( int item : this )
result=count(item);
if ( result > max )
max = result;
result = item;
System.out.printf( "%d ", max );
return max;
//===========================================================================
}
Maybe you are looking for
-
Weblogic 10.3.2 as a replacement of OAS 10g full of Oracle Forms
hello, quick question: Can I take a entire system in Oracle Forms with OAS 10g technology and deploy them on a Weblogic 10.3.2 as an upgrade/replacement option ? Can weblogic run Oracle forms out of the box or is there a vendor lock-in trick ? Thanks
-
On my 2012 MBP I can no longer use dual screens/HDMI after upgrading to 10.8.2. I'm using Moshi Thunderbolt adapter
-
What's wrong with the following query? It returns nothing. SELECT extractValue(OBJECT_VALUE, '/bulkCmConfigDataFile/configData/SubNetwork/SubNetwork/MeContext/VsDataContainer/@id') FROM test; Here is the XML file: <?xml version="1.0" encoding="UTF-8"
-
Why can't I see the whole image?
I can not see the whole image in the viewing area. All I get is a partial rectangular section, with the rest being either white, or checkerboard. It doesn't matter what size the image is, nor how many layers, or even whether I use the 32 or 64 bit ve
-
DB13 initiated backups fail - BRTOOLS succeeds
Dear All, I have configured init<SID>.sap for a online disk backup. When I start a online backup from BRTOOLS it completes. But when I schedule or immediately start a Online backup from DB13, it fails with this log: 01.09.2008 12:09:47 BR0282