I need to display an array of doubles on a table and I am loosing my percision
Hello,
I need to display an array of doubles on a table but I am losing my decimal precision. I am converting the array to a string in order to display it on the table with a number to decimal function. This is where I lose my precision since that control converts the double into an integer and then into the string. What control do I need to use instead of that in order to preserve my decimal precision all the way to the table? I have attached my VI. Thanks in advance!
Gregory Osenbach, CLA
Fluke
Attachments:
canalyzer_prototype_1.vi 52 KB
Thank you both for the quick response. Its just the info I needed!
Gregory Osenbach, CLA
Fluke
Similar Messages
-
How to insert array of records in Storage table and Nested table same time??
Hi,
I am using ProC++ ( Oracle 8i) . I want to insert a host array
in a table. That table has a nested table in it. So for every
record in my host array, there are muliple records to be
inserted in Nested table. How is this possible using pro*C??
Pls help.
Thanks
NiveditaHave a look at the Oracle 9i PL/SQL manual, which has an example.
-
Help needed to display character vaiable in currency format
Hi Friends
In a SAP Script I am passing a currency field to the subroutine as an i/p parameter and since it gets converted to character format in subroutine because of 'itcsy' , ihave deleted the trailing zeroes and decimal points from the field and performed calculations on the field, now i need to pass this char field back to SAP script but i need to display that field in currency format with commas and decimal points in the script...how do i do that???
Thanks
Vishal.Hi Vishal,
When you pass the currency amount into the perform, no need to remove the trailing zeros and the decimal point.
Only thing you need to remove is the comma seperator as it gives a runtime error during calculation.
To convert it back to the format with comma, write the below command:
WRITE v_Item_total currency '2' to v_item_char.
CONDENSE v_item_char.
Here v_item_total is a number which is converted to comma seperated number and passed to char variable.
This char variable is then passed to the SCRIPT.
regards,
Gaurav. -
Populating two dynamic internal tables and displaying the O/p as ALV
I want to develop a abap prototype program report for the SD document flow analysis...
There is a Fm : RV_ORDER_FLOW_INFORMATION in which if we pass the Sales order number it returns the flows as VBFA_TAB.
I need to populate two dynamic ITAB1 and ITAB2
the structure of ITAB1 should be like ColNm1....ColNmn
The values for ColNm1 will be Sales Order ColNm2 as Delivery or smthng else depending on field vbtyp_n.
ITAB 2 should have the corresponding values accly to ITAB1.
Then we need to display in ALV o/p.
The tables should be populated dynamically.
Can anybody throw some light on it and plz do write back with sample code to do the logic of it.Search in SDN with Dynamic internal tables.
you get lot of code samples and Discussions related to Dynamic internal tables.
you can also check with this class CL_ALV_TABLE_CREATE -
I need help on displaying parallel arrays
I have created 3 one dimentional arrays and need to pass that array to a method and within the method the program should be able to accept an input from the user. The input should be matched with an array subscript value. I after, I need to display only the array subscript values of the matching input and the subscript values of 2 more parallel arrays
I need to be able to display only the values of the matching subscripts
like be able to display the subscript [3]which is a match with the input and the subscript [3] from the other 2 arrays.
Can someone please help me?I have created 3 one dimentional arrays and need to
pass that array to a method and within the method the
program should be able to accept an input from the
user. one array, or all arrays? either way do you have problems in passing them into a method? if so are you famililar with parameter passing and java syntax?
The input should be matched with an array
subscript value. traverse the subscript and do this:
for(int i=0; i<=myarray.length; i++)
if (myarray[i] = intergerPassed)
//do whatever
//eg. System.out.println("matched on "+i);
//or System.out.println("other arrays have values at this subscript"+ myarray2[i]+" and "+myarray3);
I after, I need to display only the
array subscript values of the matching input and the
subscript values of 2 more parallel arrays
I need to be able to display only the values of the
matching subscripts
like be able to display the subscript [3]which is a
match with the input and the subscript [3] from the
other 2 arrays.
Can someone please help me? -
Need to display two ALV GRIDs in a single screen
Hi,
I have a question, i'm using version 4.6. I want to display 2 ALVs in a single screen or by calling.
Step 1 : The internal table (which holds the data for the ALVs has to be populated before calling ALV1 or ALV2)
Step 2 : Display In a single report
ALV1 report (Editable ,Has to be a GRID)
ALV2 report (Non Editable, Has to be a GRID)
(or)
Step 1 : The internal table (which holds the data for the ALVs has to be populated before calling ALV1 or ALV2)
Step 2 :
ALV1 report (Editable ,Has to be a GRID, with a custom button to call ALV2 hiding the ALV1 ie not visible to user)
ALV2 report (Non Editable ,Has to be a GRID, with a custom button to call ALV1 hiding the ALV2 ie not visible to user)
Please help me <b><REMOVED BY MODERATOR></b>
Message was edited by:
Alvaro Tejada GalindoHi
ABAP List Viewer
Simple ALV report
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
ALV
1. Please give me general info on ALV.
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
2. How do I program double click in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=11601
http://www.sapfans.com/forums/viewtopic.php?t=23010
Check the program in the following link:
http://sap-img.com/abap/display-secondary-list-using-alv-grid.htm
3. How do I add subtotals (I have problem to add them)...
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_basic.htm
4. How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
5. How to print page number / total number of pages X/XX in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
http://www.sapfans.com/forums/viewtopic.php?t=64320
http://www.sapfans.com/forums/viewtopic.php?t=44477
7. How can I set the cell color in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=52107
8. How do I print a logo/graphics in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=81149
http://www.sapfans.com/forums/viewtopic.php?t=35498
http://www.sapfans.com/forums/viewtopic.php?t=5013
9. How do I create and use input-enabled fields in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=84933
http://www.sapfans.com/forums/viewtopic.php?t=69878
10. How can I use ALV for reports that are going to be run in background?
http://www.sapfans.com/forums/viewtopic.php?t=83243
http://www.sapfans.com/forums/viewtopic.php?t=19224
11. How can I display an icon in ALV? (Common requirement is traffic light icon).
http://www.sapfans.com/forums/viewtopic.php?t=79424
http://www.sapfans.com/forums/viewtopic.php?t=24512
12. How can I display a checkbox in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=88376
http://www.sapfans.com/forums/viewtopic.php?t=40968
http://www.sapfans.com/forums/viewtopic.php?t=6919
13. Top-of-page in ALV
selection-screen and top-of-page in ALV
14. ALV Group Heading
http://www.sap-img.com/fu037.htm
How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
15. ALV output to PDF conversion
It has an example code for PDF Conversion.
http://www.erpgenie.com/abap/code/abap51.htm
converting the output of alv in pdf
Go thru these programs they may help u to try on some hands on
ALV Demo program
BCALV_DEMO_HTML
BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
BCALV_GRID_DEMO Simple ALV Control Call Demo Program
BCALV_TREE_DEMO Demo for ALV tree control
BCALV_TREE_SIMPLE_DEMO
BC_ALV_DEMO_HTML_D0100
The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).
This helps us to implement all the features mentioned very effectively.
Using ALV, We can have three types of reports:
1. Simple Report
2. Block Report
3. Hierarchical Sequential Report
There are some function modules which will enable to produce the above reports without much effort.
All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
1. SIMPLE REPORT.
The important function modules are
a. Reuse_alv_list_display
b. Reuse_alv_fieldcatalog_merge
c. Reuse_alv_events_get
d. Reuse_alv_commentary_write
e. Reuse_alv_grid_display
A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
The important parameters are :
I. Export :
i. I_callback_program : report id
ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status
iii. I_callback_user_command : routine where the function codes are handled
iv. I_structure name : name of the dictionary table
v. Is_layout : structure to set the layout of the report
vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE
vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
II. Tables :
i. t_outtab : internal table with the data to be output
B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
The Important Parameters are :
I. Export :
i. I_program_name : report id
ii. I_internal_tabname : the internal output table
iii. I_inclname : include or the report name where all the dynamic forms are handled.
II Changing
ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
declared in the type pool SLIS.
C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
Parameters :
I. Import :
Et_Events : The event table is returned with all possible CALLBACK events
for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
II. Export :
I_List_type :
0 = simple list REUSE_ALV_LIST_DISPLAY
1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
3 = hierarchical-sequential block list
REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
Parameters :
I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
This internal table has three fields :
Typ : H header, S selection , A - action
Key : only when typ is S.
Info : the text to be printed
E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
Parameters : same as reuse_alv_list_display
This is an example for simple list.
2. BLOCK REPORT
This is used to have multiple lists continuously.
The important functions used in this report are:
A. REUSE_ALV_BLOCK_LIST_INIT
B. REUSE_ALV_BLOCK_LIST_APPEND
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_BLOCK_LIST_DISPLAY
A. REUSE_ALV_BLOCK_LIST_INIT
Parameters:
I. I_CALLBACK_PROGRAM
II. I_CALLBACK_PF_STATUS_SET
III. I_CALLBACK_USER_COMMAND
This function module is used to set the default gui status etc.
B. REUSE_ALV_BLOCK_LIST_APPEND
Parameters :
Export :
I. is_layout : layout settings for block
II. it_fieldcat : field catalog
III. i_tabname : internal table name with output data
IV. it_events : internal table with all possible events
Tables :
i. t_outtab : internal table with output data.
This function module adds the data to the block.
Repeat this function for all the different blocks to be displayed one after the other.
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
This function module is used for hierarchical sequential blocks.
D. REUSE_ALV_BLOCK_LIST_DISPLAY
Parameters : All the parameters are optional.
This function module display the list with data appended by the above function.
Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
3. Hierarchical reports :
Hierarchical sequential list output.
The function module is
A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
Parameters:
I. Export:
i. I_CALLBACK_PROGRAM
ii. I_CALLBACK_PF_STATUS_SET
iii. I_CALLBACK_USER_COMMAND
iv. IS_LAYOUT
v. IT_FIELDCAT
vi. IT_EVENTS
vii. i_tabname_header : Name of the internal table in the program containing the
output data of the highest hierarchy level.
viii. i_tabname_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
ix. is_keyinfo : This structure contains the header and item table field
names which link the two tables (shared key).
II. Tables
i. t_outtab_header : Header table with data to be output
ii. t_outtab_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using REUSE_ALV_FIELDCATALOG_MERGE.
Important Attributes :
A. col_pos : position of the column
B. fieldname : internal fieldname
C. tabname : internal table name
D. ref_fieldname : fieldname (dictionary)
E. ref_tabname : table (dictionary)
F. key(1) : column with key-color
G. icon(1) : icon
H. symbol(1) : symbol
I. checkbox(1) : checkbox
J. just(1) : (R)ight (L)eft (C)ent.
K. do_sum(1) : sum up
L. no_out(1) : (O)blig.(X)no out
M. outputlen : output length
N. seltext_l : long key word
O. seltext_m : middle key word
P. seltext_s : short key word
Q. reptext_ddic : heading (ddic)
R. ddictxt(1) : (S)hort (M)iddle (L)ong
S. datatype : datatype
T. hotspot(1) : hotspot
Regards
Anji -
Reading arrays of double from S7 with OPC & Datasocket
Hi friends:
We are developing an application with a S7-315-2DP PLC and a PC with a PCI1500PFB. We use the OPC server from Applicom. We read the data very quickly with the datasocket (arrays of boolean, arrays of doubles ...and so on, and a very big amount of data over 100 ms) but when we try to write arrays datasocket faield and we have to write item on item and the speed decrease. For intance, if we try to write doubles ( 50 items) the refresh period is over 5 seconds ( some times more since we launch the data and we read the same data on the PC). Perhaps we failed configuring the OPC but there isn´t many things to configure, perhaps the problem is the board configuration .. I don´t know.
We
try to find some examples that write an array of doubles on one time but..
Thank you for yours answers.
JaviHi Javi,
I'm not aware of any known issues writing to the Applicom OPC server. In LabVIEW there isn't anything special you need to configure to be able to write arrays of doubles through DataSocket. You can test this by using the DataSocket Server Manager, make a new member that is an array of doubles, and try reading and writing to that member. You may also want to check to make sure the data member the OPC server is expecting is an arry of doubles and not an array of singles or integers. -
Displaying byte array PDF file in Portal
Hi,
i need to display a PDF file. The PDF is stored in a byte array. This works fine when i run my code (see below) from the .jpf via the debugger/browser, but when i use it as a portlet, in the portal, it does not work ?
Any help is much appreciated.
Thanks
Mark
byte[] pdfDocument = docStore.getPDF();
ServletOutputStream outPdf = response.getOutputStream();
response.setContentType("application/pdf");
outPdf.write(pdfDocument);
outPdf.flush();
outPdf.close();Mark,
Note that the portal sets the content type (e.g, text/html) and encoding
as the portal page starts rendering. In your case, the
setContentType() would be useless since the servlet container won't let
you change it. You can either use a popup browser window for the pdf as
Kunal suggested, or use an iframe if you want to render the pdf inside
the portlet window.
Subbu
Mark Gilleece wrote:
Hi,
i need to display a PDF file. The PDF is stored in a byte array. This works fine when i run my code (see below) from the .jpf via the debugger/browser, but when i use it as a portlet, in the portal, it does not work ?
Any help is much appreciated.
Thanks
Mark
byte[] pdfDocument = docStore.getPDF();
ServletOutputStream outPdf = response.getOutputStream();
response.setContentType("application/pdf");
outPdf.write(pdfDocument);
outPdf.flush();
outPdf.close(); -
Displaying Byte Array images in coldfusion
This has been driving me crazy for a couple of days now.I
have a Java class that returns pictures stored in a DB as a Byte
Array.
I am able to display the image but that is all i am able to
do - I want to display the image name, description etc in a HTML
before i display the actual image but i can't seem to find a way to
do that.
I tried using CFcontent as well and that did not help
either.This is what i am currently doing - and all that displays on
the screen is the picture and all content before the picture is
nowhere to be seen.
Picture Name: #variables.picName#
Picture Description:#variables.picDescription#
<cfscript>
context = getPageContext();
response = context.getResponse().getResponse();
out = response.getOutputStream();
response.setContentType("image/jpeg");
response.setContentLength(arrayLen(session.picture));
out.write(session.picture);
out.flush();
out.close();
</cfscript>
Any help will be greatly appreciated.Mark,
Note that the portal sets the content type (e.g, text/html) and encoding
as the portal page starts rendering. In your case, the
setContentType() would be useless since the servlet container won't let
you change it. You can either use a popup browser window for the pdf as
Kunal suggested, or use an iframe if you want to render the pdf inside
the portlet window.
Subbu
Mark Gilleece wrote:
Hi,
i need to display a PDF file. The PDF is stored in a byte array. This works fine when i run my code (see below) from the .jpf via the debugger/browser, but when i use it as a portlet, in the portal, it does not work ?
Any help is much appreciated.
Thanks
Mark
byte[] pdfDocument = docStore.getPDF();
ServletOutputStream outPdf = response.getOutputStream();
response.setContentType("application/pdf");
outPdf.write(pdfDocument);
outPdf.flush();
outPdf.close(); -
When I try to view a page that has a Google map embedded on the page, I get the error message "a plugin is needed to display this content". However, I don't know what plugin, where to get it, etc. I've tried searching for this issue but haven't been able to come up with anyone else experiencing a similar issue, nor does there seem to be a plugin for Google Maps that I can find.
The page is here:
http://osiama.org/lodges#
The map displays when one of the links is clicked in the table.I'm not sure why, but the site uses <embed> for the map instead of <iframe>.
When Firefox wants to render an <embed>, it needs to know what type of object is being embedded, and the site doesn't supply that information, so you see a generic "I don't know how to handle this" error.
Unfortunately, I don't think there is a quick workaround for you as the end user. If you are the type to tinker, you can manually edit the code of the page in the web console as follows:
* right-click the plugin message and choose Inspect Element (Q) - the web console will open to the Inspector, with the <embed> element selected (screen shot #1)
* double-click embed and edit it to iframe, then press Enter to finish the edit
* Firefox will now load the map (screen shot #2)
This isn't a general fix-all for plugin errors, and ultimately the site will need to change this. -
Display color array then 1 second later display same array with color change
Hi there, I'm new to LabVIEW and this is my first post. I'm using LabVIEW 9.0.1
Please have a look at this simple program attached below; when I've worked out this part of the program, it will be the starting up sequence of a game
the lights need to be set to white before running the program.. When the program runs the hexadecimal 'array 2' is projected as colors on 'array'. Then 1 second later, a green light is added to the centre and displayed in 'array 4'...
I am attempting to have the green light go on on the same array after 1 second. As opposed to on array 4...
When I've figured out how to do this I'll add many more time iterations, whereby a color is changed on each one. Thus making a nice startup sequence.
any help is appreciated, thanks in advance for your help!
p.s. add 00FF0000 to the last box in 'array 2' before you hit play.
Attachments:
attempt 1.vi 10 KBI think you should learn about shift registers.
Your larger program will probably work better and be easier to modify and maintain if you use a state machine in place of the sequence structure.
Lynn -
Problem in displaying 2D array in JSF
Hi All,
Thanks to all for your previous valuable suggestions. Currently i got stucked with a problem. I need to display a two dimensional array in my JSF page and we r using JSF 1.1.
I have the following 2D String array in my backing bean
private String[][] sreDesc = new String[6][3];
I need to display them in UI. Any help will be highly appreciated.
Thanks
V KrishnaYour Q is not very clear, do you ask about only accessing 2D array ?
There is a topic about using arrays in your EL, it shows you how to access the elements of 2d array easily using the dot notation. -
I have a 1-D array of double inside of a while loop. I would like to control the execution of the while loop based on one of the numeric values in that array (like I would stop the while loop if the numeric value in the array is less than or equal to 0). How should I go about doing this?
I cant link the array directly to the "less than or equal to 0" icon because it requires a single double. Any help would be much appreciated. Thanks.
Jerryqiora wrote:
I cant link the array directly to the "less than or equal to 0" icon because it requires a single double.
Of course you can connect an array to "less than or equal to 0". The output will be a boolean array that you can feed into a "OR array elements" or "AND array elements" to get a true if either (1) at least one array element matches or (2) all elements match, respectively.
qiora wrote:
I would like to control the execution of the while loop based on one of the numeric values in that array (like I would stop the while loop if the numeric value in the array is less than or equal to 0).
If it should be based on one specific element (e.g. element(0) or element(5)), you need to get that element using "index array" and do the comparison.
The implementation will depend on your exact requirement. Your question is quite ambiguous.
LabVIEW Champion . Do more with less code and in less time . -
How to write a 2-D Array of Doubles to a binary file in LabView 8.5?
Okay, this is driving me nuts. I got a program that worked fine in LabView 8.0 but refused to write any data after my institute upgraded to LabView 8.5. The data is stored in a 2-D array of doubles and is supposed to be written to a binary file, that has been correctly opened and got a header written to it containing some meta-data of the measurement. But when the doubles from the array should be written to the file, nothing happens. All I get is an (except for the header) empty file of 786 kB. I found out that writing works if I convert the data from the array to singles right before wiring them to the "write to binary file" VI, but for several reasons I need the data as doubles. Can anyone help me? I've tried everything anyone has written here about writing to binary files and more.
Remember, it worked perfectly fine with an older version of LabView. Any ideas?It is possible that you run into a known memory optimization bug.
Try to place an "always copy" primitive as discussed here.
Message Edited by altenbach on 11-18-2008 09:11 AM
LabVIEW Champion . Do more with less code and in less time . -
I'm working on creating an array that is basically a deck of cards, this is the problem.
I'm getting this error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
void main()
final int ARRAY_SIZE = 52;
String[] deck = new String[ARRAY_SIZE];
String[] cardValue = new String[]{"A","2","3","4","5","6","7","8","9","T","J","Q","K"};
String[] cardSuit = new String[]{"C","H","D","S"};
for (int count = 0; count < ARRAY_SIZE; count++)
deck[count]= cardValue[count] + cardSuit[count];
}I Know that this is because cardSuit is reaching the end of the array, but how do I keep this from happening and make it start from the beginning until i reach the end of the cardValue array?By the way thanks for the help guys, I'm in a pinch for this assignment and I appreciate all of the help.
void main()
final int ARRAY_SIZE = 52;
String[] deck = new String[ARRAY_SIZE];
String[] cardValue = new String[]{"A","2","3","4","5","6","7","8","9","T","J","Q","K"};
String[] cardSuit = new String[]{"C","H","D","S"};
for (int count = 0; count < ARRAY_SIZE; count++)
deck[count]= cardValue[count % 13] + cardSuit[count % 4];
showCards(deck);
void showCards(String [] list)
String cards = ("card");
for (int count = 0; count < list.length; count++)
print (cards);
This is what I'm talking about. I need to be able to call the showCards method and have it display whatever cards are currently in the players hand regardless of how many cards there are. I believe that I'm right when I used the void declaration because I don't want it the method to return anything to itself.
Right now with the code as is, i get "card" typed out 52 times.
First how do I go about having it print out the complete deck and the order that they are in?
Is there a way to create the deck in pre-sorted like I have below?
This was the assignment:
Write a ConsoleProgram to create a deck of playing cards, shuffle them, and deal out 5 cards to the player. To do this:
� You will need an array of 52 cards. In the basic version of this program, each card is a string in the form �XY�, where X is the rank (A, 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, A) and Y is a letter designating the suite (C, H, D, S).
� You will need to shuffle the cards by swapping the positions of two randomly selected cards in the array. For this, you should write and use three methods:
o randRange � a method which takes 2 parameters: a minimum integer and a maximum integer. It creates a random integer in this range and returns it.
o swap � a method which takes 3 parameters: an array of cards and two subscripts. It swaps the array elements with the given subscripts and returns nothing in its name.
o shuffle � a method which takes 2 parameters: an array of cards and a number of times to swap cards. It shuffles by swapping two randomly selected cards the desired number of times (a possibly different pair each time). It returns nothing in its name (so it is a void method).
� You will need an array of 5 cards for the player�s hand. After shuffling the deck, you will fill this array with the first 5 cards from the deck.
� Display the unshuffled deck, then the shuffled deck, and finally the player�s hand. Indicate which is which in the output. For example, the output of one program run might look like this: Unshuffled: 2C, 3C, 4C, 5C, 6C, 7C, 8C, 9C, TC, JC, QC, KC, AC, 2D, 3D, 4D, 5D, 6D, 7D, 8D, 9D, TD, JD, QD, KD, AD, 2H, 3H, 4H, 5H, 6H, 7H, 8H, 9H, TH, JH, QH, KH, AH, 2S, 3S, 4S, 5S, 6S, 7S, 8S, 9S, TS, JS, QS, KS, AS Shuffled: 2C, QC, 3S, 9C, 9S, 6C, 6H, 3C, QH, 2H, 8C, 9H, AH, 4S, AS, TH, 6D, 3D, 2S, 8S, 5C, TC, 4C, 4D, 7C, AD, 9D, JD, 4H, 5S, KH, 7H, JS, 8D, TD, KC, 3H, 2D, KD, AC, KS, JC, 5H, JH, 8H, 5D, 7S, TS, QD, 7D, 6S, QS Your Hand: 2C, QC, 3S, 9C, 9S
Maybe you are looking for
-
Help appending how many times an event ID has occurred next to the unique Event ID.
Hello, I am trying to figure out how to find how many times an event occurred and then append that next to the single -unique Event ID. The closest I can find is the Sort-Object Count but I can't figure out how to get that work within the below scri
-
Hi everyone: When I start up my laptop, I'd like to simply see my desktop and have no programs (in this case Firefox or MS-Word) open without me manually opening those programs. Thanks in advance for your assistance, Michael
-
Search drivers for Creative webcam N10225, PD1110 on Windows Vista 64
I'm searching drivers to run my webcam on a Pc with windows vista 64 Creative webcam N10225, PD1110 Thank You
-
I recently changed country associated with my itunes account. My music has stayed on my iphone but I am outraged to discover that when moving country and you change your bank details that your previous movie purchases seem to disappear. Is this corre
-
Any concerns with a 5th HDD in 2nd optical bay?
I'm thinking of adding a fifth hard disk drive to my Mac Pro 2.8GHz Quad-Core (Mid 2010) "Nehalem" machine. I'll use if for storing audio sample libraries, some of which will be used in streaming playback. Are there any special concerns or considerat